Skip to content

Commit

Permalink
fix offsets
Browse files Browse the repository at this point in the history
  • Loading branch information
vadiminshakov committed Jan 6, 2025
1 parent dd53b0b commit d98319c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func calculateLastOffset(fd *os.File) (int64, error) {
decoder := gob.NewDecoder(fd)
for {
var msg msg
offset, err := fd.Seek(0, io.SeekCurrent)
offset, err := fd.Seek(io.SeekCurrent, 0)
if err != nil {
return 0, errors.Wrap(err, "failed to get current offset")
}
Expand All @@ -163,7 +163,7 @@ func calculateLastOffset(fd *os.File) (int64, error) {
}

// set offset to the beginning of the file
if _, err := fd.Seek(0, io.SeekStart); err != nil {
if _, err := fd.Seek(lastOffset, io.SeekStart); err != nil {
return 0, errors.Wrap(err, "failed to seek to the beginning of the file")
}

Expand Down

0 comments on commit d98319c

Please sign in to comment.