aboutsummaryrefslogtreecommitdiffstats
path: root/drive/download.go
diff options
context:
space:
mode:
authorPetter Rasmussen2016-02-20 23:30:30 +0100
committerPetter Rasmussen2016-02-20 23:39:12 +0100
commit28c4eb923fd01d892a17844328d0090830bcd229 (patch)
treeead9f5722894f36c3b641df89a2226ce9094b4dd /drive/download.go
parenta9e9da783481fcb8022eb52fb944cb9ee13997de (diff)
downloadgdrive-28c4eb923fd01d892a17844328d0090830bcd229.tar.bz2
Wrap downloads in TimeoutReader
Diffstat (limited to 'drive/download.go')
-rw-r--r--drive/download.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/drive/download.go b/drive/download.go
index 7d3dc8b..a33373f 100644
--- a/drive/download.go
+++ b/drive/download.go
@@ -75,7 +75,10 @@ func (self *Drive) downloadRecursive(args DownloadArgs) error {
}
func (self *Drive) downloadBinary(f *drive.File, args DownloadArgs) (int64, int64, error) {
- res, err := self.service.Files.Get(f.Id).Download()
+ // Get timeout reader wrapper and context
+ timeoutReaderWrapper, ctx := getTimeoutReaderWrapperContext()
+
+ res, err := self.service.Files.Get(f.Id).Context(ctx).Download()
if err != nil {
return 0, 0, fmt.Errorf("Failed to download file: %s", err)
}
@@ -92,7 +95,7 @@ func (self *Drive) downloadBinary(f *drive.File, args DownloadArgs) (int64, int6
return self.saveFile(saveFileArgs{
out: args.Out,
- body: res.Body,
+ body: timeoutReaderWrapper(res.Body),
contentLength: res.ContentLength,
fpath: fpath,
force: args.Force,