Repository navigation
Conversation
|
Thanks you for the PR :-) I'd like to fix it differently, though. The common way to get an object's size is: size, _ := f.Seek(ctx, 0, io.SeekEnd)
_, _ = f.Seek(ctx, 0, io.SeekStart)On master this happens to be free, because the second seek does nothing. With this PR it closes and reopens the connection, which costs an extra request and turns off the MD5 check :-( In rclone we deal with this by letting the caller seek wherever they like and only reopening the stream when a read actually happens. Could you rework the PR that way? Roughly:
This does mean errors from reopening, such as a deleted object, show up on the next Please keep your existing test and add these cases:
Thanks again! |
After
Seek(0, io.SeekEnd)returns the object length,Seek(0, io.SeekCurrent)still returns the old read position. The position query also clears the virtual EOF flag, allowing reads from the old response.Store the new end position, preserve virtual EOF through position queries and no-op seeks, and clear it after a successful range reopen. Update the outdated Seek documentation. Fixes #193.
The regression exercises fresh and partially read objects, exact and beyond EOF, repeated queries/no-op seeks, relative backwards reads and rewind. It fails all four cases on unchanged master. The full root package suite passes on Go 1.24.13 and 1.25.14;
go build ./..., configured golangci-lint 1.64.8 and formatting checks pass. Independent HTTP caller and race controls also pass. These use local HTTP fixtures; Docker/live Swift integration was not run because the Docker socket is unavailable to this user.Seeking back from the corrected end position now reopens the response. As with other actual seeks, that uses the existing behavior that disables whole-object hash validation after reopening.