Skip to content

Commit 7e9082f

Browse files
OvearPIKACHUIM
andauthored
fix(stream): allow seeking beyond file size per Go convention (#2667)
Remove `offset > size` guard from RangeReadReadAtSeeker.Seek and DynamicReadAtSeeker.Seek. Go's io.Seeker convention allows seeking past EOF. Co-authored-by: Pikachu Ren <40362270+PIKACHUIM@users.noreply.github.com>
1 parent 6d4ad58 commit 7e9082f

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

‎internal/stream/stream.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ func (r *RangeReadReadAtSeeker) Seek(offset int64, whence int) (int64, error) {
519519
default:
520520
return 0, errors.New("Seek: invalid whence")
521521
}
522-
if offset < 0 || offset > r.ss.GetSize() {
522+
if offset < 0 {
523523
return 0, errors.New("Seek: invalid offset")
524524
}
525525
r.masterOff = offset

‎pkg/buffer/utils.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func (r *DynamicReadAtSeeker) Seek(offset int64, whence int) (int64, error) {
7979
return 0, errors.New("Seek: invalid whence")
8080
}
8181

82-
if offset < 0 || offset > r.block.Size() {
82+
if offset < 0 {
8383
return 0, errors.New("Seek: invalid offset")
8484
}
8585
r.offset = offset

0 commit comments

Comments
 (0)