Closed donny-dont closed 4 years ago
Hello!
Thanks for pointing to io.ReadFrom
, indeed it wasn't accounted for. Commit 9436aa1 should fix this. If you have time and interest to implement a proxy for writer side, I'd be glad to review a PR.
You mentioned sftp.File
which is a good use case for proxy reader, can you think of any use case for proxy writer?
I've done this externally in a library I wrote to wrap mpb
. Most relavant parts:
are here: https://github.com/nektro/go-util/blob/master/mbpp/mbpp.go#L144
and here: https://github.com/nektro/go-util/blob/master/mbpp/headlessbar.go
I think the title of the issue is a bit misleading, because @donny-dont asked for io.WriterTo
interface to be implemented, so that io.Copy
can benefit, if used with internal proxy reader. As this is done I'm closing this issue.
@nektro thanks for interesting code, anyway.
The
io.Copy
function has optimizations where the Reader implementsio.ReadFrom
.For example
sftp.File
implementsio.ReadFrom
. So if you attempt to download a file fromsftp
and wrap it with ampb.proxyReader
thenio.Copy
is unable to use theio.ReaderFrom
optimization.I was thinking about migrating from https://github.com/cheggaaa/pb to mpb since it has multiple progress bar support and noticed that mpb just proxies a reader. Would it be of interest to do a writer proxy as well?