aboutsummaryrefslogtreecommitdiffstats
path: root/drive/download.go
diff options
context:
space:
mode:
Diffstat (limited to 'drive/download.go')
-rw-r--r--drive/download.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/drive/download.go b/drive/download.go
index 31bcc58..e5674ad 100644
--- a/drive/download.go
+++ b/drive/download.go
@@ -8,9 +8,9 @@ import (
type DownloadFileArgs struct {
Out io.Writer
+ Progress io.Writer
Id string
Force bool
- NoProgress bool
Stdout bool
}
@@ -30,9 +30,12 @@ func (self *Drive) Download(args DownloadFileArgs) (err error) {
// Close body on function exit
defer res.Body.Close()
+ // Wrap response body in progress reader
+ srcReader := getProgressReader(res.Body, args.Progress, res.ContentLength)
+
if args.Stdout {
// Write file content to stdout
- _, err := io.Copy(os.Stdout, res.Body)
+ _, err := io.Copy(args.Out, srcReader)
return err
}
@@ -51,7 +54,7 @@ func (self *Drive) Download(args DownloadFileArgs) (err error) {
defer outFile.Close()
// Save file to disk
- bytes, err := io.Copy(outFile, res.Body)
+ bytes, err := io.Copy(outFile, srcReader)
if err != nil {
return fmt.Errorf("Failed saving file: %s", err)
}