pb icon indicating copy to clipboard operation
pb copied to clipboard

feature req: ProxyReadSeeker

Open nergdron opened this issue 3 years ago • 2 comments

I'm in need of a ProxyReadSeeker to wrap ReadSeekers (like files) for use with the AWS go SDK. stuff like s3.PutObject() says it takes an io.Reader, but really requires an io.ReadSeeker since it reads the data once to calculate checksums and then again to send it to S3.

I'm envisioning that the progress bar goes backwards when it seeks back, and then moves forwards again, basically tracking the current read position as it goes. Hopefully shouldn't be too hard to implement. I'm willing to take a stab at it, if you agree to the general design.

nergdron avatar Dec 14 '20 21:12 nergdron

the other option I'm thinking about is extending ProxyReader to just handle Seek calls like it handles Close calls, but always return an error if you call Seek() on something that isn't a Seeker underneath. this would mean less code, both in the implementation and in the io_test.go. feedback appreciated!

nergdron avatar Dec 14 '20 22:12 nergdron

We can't just add Seek to the reader. Some packages can take io.Reader in arguments, but inside do a type check for io.Seeker - in this case, we can mess up the logic. ProxyReaderSeeker is a solution, but with Seek, it is impossible to correctly calculate the progress (speed, remaining time, etc.) I think it's ok and users will keep this in mind.

cheggaaa avatar Dec 15 '20 09:12 cheggaaa