google / skicka

Command-line utility for working with Google Drive. Join the mailing list at https://groups.google.com/forum/#!forum/skicka-users.
Apache License 2.0
1.3k stars 119 forks source link

Run the progressbar based on file transfer size #32

Closed gusennan closed 9 years ago

gusennan commented 9 years ago

This addresses Issue #15. Now both uploads and downloads display progress based on the total number of bytes transferred out of the total bytes to be transferred. In order to accomplish this, the determination of what would be sync'd before the actual sync has to be separated into its own logical components, whereas currently in master the logic to transport the bits up and down and the determiner of what is going up and down are intertwined. That's why there's a decent amount of moving around of code.

mmp commented 9 years ago

Very nice--looks good!

For uploads of large files, it would be nice to update the progress bar over the course of uploads (rather than when each file upload is complete), as you did for downloads, but in any case this is a big improvement!

gusennan commented 9 years ago

Thanks. Regarding the error checking comment, I'll get it in the next PR.

I agree about the behavior of the progress bar for uploads and thought about how it could be accomplished unfruitfully. It didn't seem that it could work with the same mechanism as the download, which receives an io.Writer and allows the progress bar to piggy back on the writer via the io.MultiWriter. The oAuthTransport.RoundTrip() call on 1025 requires an http.Request type, not an io.Writer type, which precludes using the io.MultiWriter method.

I'm sure there's other ways though, just would need to dig around a bit more. If you have any ideas that could work I'd be happy to attempt an implementation.

mmp commented 9 years ago

Maybe something with io.Pipe? (I haven't used it before, so am not sure).

Alternatively, it might be possible to hook into the RateLimitedReader and have it update the progress bar, though that seems a little hacky. "RateLimitedProgressBarUpdatingReader"? (Ugh!)