Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Commit

Permalink
io: correctly handle seek offset with io.SeekEnd
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Jan 29, 2019
1 parent 9dacd09 commit cdb64d5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion io/dagreader.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ func (dr *dagReader) Seek(offset int64, whence int) (int64, error) {
// searches in the `Walker` (see `Walker.Seek`).

case io.SeekEnd:
return dr.Seek(int64(dr.Size())-offset, io.SeekStart)
return dr.Seek(int64(dr.Size())+offset, io.SeekStart)

default:
return 0, errors.New("invalid whence")
Expand Down
2 changes: 1 addition & 1 deletion io/dagreader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestRelativeSeek(t *testing.T) {
}
}

_, err = reader.Seek(4, io.SeekEnd)
_, err = reader.Seek(-4, io.SeekEnd)
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit cdb64d5

Please sign in to comment.