From b61912b4c88f8be36f5921adbc3918b94d5cc048 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sun, 22 Aug 2021 17:21:19 +0100 Subject: [PATCH] box: add --box-list-chunk to control listing chunk size #5545 --- backend/box/box.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/backend/box/box.go b/backend/box/box.go index ad4968496..f90078d0d 100644 --- a/backend/box/box.go +++ b/backend/box/box.go @@ -56,7 +56,6 @@ const ( decayConstant = 2 // bigger for slower decay, exponential rootURL = "https://api.box.com/2.0" uploadURL = "https://upload.box.com/api/2.0" - listChunks = 1000 // chunk size to read directory listings minUploadCutoff = 50000000 // upload cutoff can be no lower than this defaultUploadCutoff = 50 * 1024 * 1024 tokenURL = "https://api.box.com/oauth2/token" @@ -133,6 +132,11 @@ func init() { Help: "Max number of times to try committing a multipart file.", Default: 100, Advanced: true, + }, { + Name: "list_chunk", + Default: 1000, + Help: "Size of listing chunk 1-1000.", + Advanced: true, }, { Name: config.ConfigEncoding, Help: config.ConfigEncodingHelp, @@ -247,6 +251,7 @@ type Options struct { Enc encoder.MultiEncoder `config:"encoding"` RootFolderID string `config:"root_folder_id"` AccessToken string `config:"access_token"` + ListChunk int `config:"list_chunk"` } // Fs represents a remote box @@ -577,7 +582,7 @@ func (f *Fs) listAll(ctx context.Context, dirID string, directoriesOnly bool, fi Path: "/folders/" + dirID + "/items", Parameters: fieldsValue(), } - opts.Parameters.Set("limit", strconv.Itoa(listChunks)) + opts.Parameters.Set("limit", strconv.Itoa(f.opt.ListChunk)) opts.Parameters.Set("usemarker", "true") var marker *string OUTER: @@ -1103,7 +1108,7 @@ func (f *Fs) CleanUp(ctx context.Context) (err error) { "fields": []string{"type", "id"}, }, } - opts.Parameters.Set("limit", strconv.Itoa(listChunks)) + opts.Parameters.Set("limit", strconv.Itoa(f.opt.ListChunk)) opts.Parameters.Set("usemarker", "true") var marker *string for {