From 7679620f4bc3f7ca92d584ee0d2ae5e496b6886e Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Thu, 29 Dec 2016 18:04:37 +0000 Subject: [PATCH] drive: Experimentally add --drive-list-chunk --- drive/drive.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drive/drive.go b/drive/drive.go index 48d8fa437..9f53094da 100644 --- a/drive/drive.go +++ b/drive/drive.go @@ -21,6 +21,7 @@ import ( "github.com/ncw/rclone/oauthutil" "github.com/ncw/rclone/pacer" "github.com/pkg/errors" + "github.com/spf13/pflag" "golang.org/x/oauth2" "golang.org/x/oauth2/google" "google.golang.org/api/drive/v2" @@ -46,6 +47,7 @@ var ( driveUseTrash = fs.BoolP("drive-use-trash", "", false, "Send files to the trash instead of deleting permanently.") driveSkipGdocs = fs.BoolP("drive-skip-gdocs", "", false, "Skip google documents in all listings.") driveExtensions = fs.StringP("drive-formats", "", defaultExtensions, "Comma separated list of preferred formats for downloading Google docs.") + driveListChunk = pflag.Int64P("drive-list-chunk", "", 1000, "Size of listing chunk 100-1000. 0 to disable.") // chunkSize is the size of the chunks created during a resumable upload and should be a power of two. // 1<<18 is the minimum size supported by the Google uploader, and there is no maximum. chunkSize = fs.SizeSuffix(8 * 1024 * 1024) @@ -219,7 +221,10 @@ func (f *Fs) listAll(dirID string, title string, directoriesOnly bool, filesOnly query += fmt.Sprintf(" and mimeType!='%s'", driveFolderType) } // fmt.Printf("listAll Query = %q\n", query) - list := f.svc.Files.List().Q(query).MaxResults(1000) + list := f.svc.Files.List().Q(query) + if *driveListChunk > 0 { + list = list.MaxResults(*driveListChunk) + } OUTER: for { var files *drive.FileList