box: add --box-list-chunk to control listing chunk size #5545

This commit is contained in:
Nick Craig-Wood 2021-08-22 17:21:19 +01:00
parent bfecf5301b
commit b61912b4c8

View File

@ -56,7 +56,6 @@ const (
decayConstant = 2 // bigger for slower decay, exponential decayConstant = 2 // bigger for slower decay, exponential
rootURL = "https://api.box.com/2.0" rootURL = "https://api.box.com/2.0"
uploadURL = "https://upload.box.com/api/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 minUploadCutoff = 50000000 // upload cutoff can be no lower than this
defaultUploadCutoff = 50 * 1024 * 1024 defaultUploadCutoff = 50 * 1024 * 1024
tokenURL = "https://api.box.com/oauth2/token" tokenURL = "https://api.box.com/oauth2/token"
@ -133,6 +132,11 @@ func init() {
Help: "Max number of times to try committing a multipart file.", Help: "Max number of times to try committing a multipart file.",
Default: 100, Default: 100,
Advanced: true, Advanced: true,
}, {
Name: "list_chunk",
Default: 1000,
Help: "Size of listing chunk 1-1000.",
Advanced: true,
}, { }, {
Name: config.ConfigEncoding, Name: config.ConfigEncoding,
Help: config.ConfigEncodingHelp, Help: config.ConfigEncodingHelp,
@ -247,6 +251,7 @@ type Options struct {
Enc encoder.MultiEncoder `config:"encoding"` Enc encoder.MultiEncoder `config:"encoding"`
RootFolderID string `config:"root_folder_id"` RootFolderID string `config:"root_folder_id"`
AccessToken string `config:"access_token"` AccessToken string `config:"access_token"`
ListChunk int `config:"list_chunk"`
} }
// Fs represents a remote box // 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", Path: "/folders/" + dirID + "/items",
Parameters: fieldsValue(), Parameters: fieldsValue(),
} }
opts.Parameters.Set("limit", strconv.Itoa(listChunks)) opts.Parameters.Set("limit", strconv.Itoa(f.opt.ListChunk))
opts.Parameters.Set("usemarker", "true") opts.Parameters.Set("usemarker", "true")
var marker *string var marker *string
OUTER: OUTER:
@ -1103,7 +1108,7 @@ func (f *Fs) CleanUp(ctx context.Context) (err error) {
"fields": []string{"type", "id"}, "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") opts.Parameters.Set("usemarker", "true")
var marker *string var marker *string
for { for {