aboutsummaryrefslogtreecommitdiffstats
path: root/drive/download.go
diff options
context:
space:
mode:
Diffstat (limited to 'drive/download.go')
-rw-r--r--drive/download.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/drive/download.go b/drive/download.go
index 0856258..ec1af8a 100644
--- a/drive/download.go
+++ b/drive/download.go
@@ -19,6 +19,7 @@ type DownloadArgs struct {
Recursive bool
Delete bool
Stdout bool
+ Timeout time.Duration
}
func (self *Drive) Download(args DownloadArgs) error {
@@ -120,10 +121,13 @@ func (self *Drive) downloadRecursive(args DownloadArgs) error {
func (self *Drive) downloadBinary(f *drive.File, args DownloadArgs) (int64, int64, error) {
// Get timeout reader wrapper and context
- timeoutReaderWrapper, ctx := getTimeoutReaderWrapperContext()
+ timeoutReaderWrapper, ctx := getTimeoutReaderWrapperContext(args.Timeout)
res, err := self.service.Files.Get(f.Id).Context(ctx).Download()
if err != nil {
+ if isTimeoutError(err) {
+ return 0, 0, fmt.Errorf("Failed to download file: timeout, no data was transferred for %v", args.Timeout)
+ }
return 0, 0, fmt.Errorf("Failed to download file: %s", err)
}