aboutsummaryrefslogtreecommitdiffstats
path: root/drive/update.go
diff options
context:
space:
mode:
Diffstat (limited to 'drive/update.go')
-rw-r--r--drive/update.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/drive/update.go b/drive/update.go
index 156eb2f..2ab684e 100644
--- a/drive/update.go
+++ b/drive/update.go
@@ -20,6 +20,7 @@ type UpdateArgs struct {
Mime string
Recursive bool
ChunkSize int64
+ Timeout time.Duration
}
func (self *Drive) Update(args UpdateArgs) error {
@@ -57,13 +58,16 @@ func (self *Drive) Update(args UpdateArgs) error {
progressReader := getProgressReader(srcFile, args.Progress, srcFileInfo.Size())
// Wrap reader in timeout reader
- reader, ctx := getTimeoutReaderContext(progressReader)
+ reader, ctx := getTimeoutReaderContext(progressReader, args.Timeout)
fmt.Fprintf(args.Out, "Uploading %s\n", args.Path)
started := time.Now()
f, err := self.service.Files.Update(args.Id, dstFile).Fields("id", "name", "size").Context(ctx).Media(reader, chunkSize).Do()
if err != nil {
+ if isTimeoutError(err) {
+ return fmt.Errorf("Failed to upload file: timeout, no data was transferred for %v", args.Timeout)
+ }
return fmt.Errorf("Failed to upload file: %s", err)
}