From 1fd9b483c887e79ece458e094403075a0470407b Mon Sep 17 00:00:00 2001 From: Nick Gaya Date: Sun, 4 Apr 2021 01:08:16 -0700 Subject: [PATCH] onedrive: add list_chunk option Add --onedrive-list-chunk option similar to existing options for azureblob, drive, and s3. Suggested as a workaround for a OneDrive pagination bug See: https://forum.rclone.org/t/unexpected-duplicates-on-onedrive-with-0s-in-filename/23164/8 --- backend/onedrive/onedrive.go | 8 +++++++- docs/content/flags.md | 1 + docs/content/onedrive.md | 9 +++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/backend/onedrive/onedrive.go b/backend/onedrive/onedrive.go index 17e505a60..371de6534 100755 --- a/backend/onedrive/onedrive.go +++ b/backend/onedrive/onedrive.go @@ -361,6 +361,11 @@ This will only work if you are copying between two OneDrive *Personal* drives AN the files to copy are already shared between them. In other cases, rclone will fall back to normal copy (which will be slightly slower).`, Advanced: true, + }, { + Name: "list_chunk", + Help: "Size of listing chunk.", + Default: 1000, + Advanced: true, }, { Name: "no_versions", Default: false, @@ -468,6 +473,7 @@ type Options struct { DriveType string `config:"drive_type"` ExposeOneNoteFiles bool `config:"expose_onenote_files"` ServerSideAcrossConfigs bool `config:"server_side_across_configs"` + ListChunk int64 `config:"list_chunk"` NoVersions bool `config:"no_versions"` LinkScope string `config:"link_scope"` LinkType string `config:"link_type"` @@ -896,7 +902,7 @@ type listAllFn func(*api.Item) bool func (f *Fs) listAll(ctx context.Context, dirID string, directoriesOnly bool, filesOnly bool, fn listAllFn) (found bool, err error) { // Top parameter asks for bigger pages of data // https://dev.onedrive.com/odata/optional-query-parameters.htm - opts := f.newOptsCall(dirID, "GET", "/children?$top=1000") + opts := f.newOptsCall(dirID, "GET", fmt.Sprintf("/children?$top=%d", f.opt.ListChunk)) OUTER: for { var result api.ListChildrenResponse diff --git a/docs/content/flags.md b/docs/content/flags.md index 58cfd3b61..48d37d4ea 100755 --- a/docs/content/flags.md +++ b/docs/content/flags.md @@ -415,6 +415,7 @@ and may be set in the config file. --onedrive-link-password string Set the password for links created by the link command. --onedrive-link-scope string Set the scope of the links created by the link command. (default "anonymous") --onedrive-link-type string Set the type of the links created by the link command. (default "view") + --onedrive-list-chunk int Size of listing chunk. (default 1000) --onedrive-no-versions Remove all versions on modifying operations --onedrive-region string Choose national cloud region for OneDrive. (default "global") --onedrive-server-side-across-configs Allow server-side operations (e.g. copy) to work across different onedrive configs. diff --git a/docs/content/onedrive.md b/docs/content/onedrive.md index e3cdbf336..60e31ea4d 100644 --- a/docs/content/onedrive.md +++ b/docs/content/onedrive.md @@ -325,6 +325,15 @@ fall back to normal copy (which will be slightly slower). - Type: bool - Default: false +#### --onedrive-list-chunk + +Size of listing chunk. + +- Config: list_chunk +- Env Var: RCLONE_ONEDRIVE_LIST_CHUNK +- Type: int +- Default: 1000 + #### --onedrive-no-versions Remove all versions on modifying operations