From 74d5477fadfdd9f309d242894f39f6fa332b523f Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sun, 26 Nov 2023 15:54:13 +0000 Subject: [PATCH] onedrive: add --onedrive-delta flag to enable ListR Before this change ListR was unconditionally enabled on onedrive. This caused performance problems for some uses, so now the --onedrive-delta flag has to be supplied. Fixes #7362 --- backend/onedrive/onedrive.go | 37 ++++++++++++++++++++++++++++++++++++ docs/content/onedrive.md | 3 +++ docs/content/overview.md | 4 +++- 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/backend/onedrive/onedrive.go b/backend/onedrive/onedrive.go index 7a90e28ad..fbbdcac47 100644 --- a/backend/onedrive/onedrive.go +++ b/backend/onedrive/onedrive.go @@ -324,6 +324,37 @@ the --onedrive-av-override flag, or av_override = true in the config file. `, Advanced: true, + }, { + Name: "delta", + Default: false, + Help: strings.ReplaceAll(`If set rclone will use delta listing to implement recursive listings. + +If this flag is set the the onedrive backend will advertise |ListR| +support for recursive listings. + +Setting this flag speeds up these things greatly: + + rclone lsf -R onedrive: + rclone size onedrive: + rclone rc vfs/refresh recursive=true + +**However** the delta listing API **only** works at the root of the +drive. If you use it not at the root then it recurses from the root +and discards all the data that is not under the directory you asked +for. So it will be correct but may not be very efficient. + +This is why this flag is not set as the default. + +As a rule of thumb if nearly all of your data is under rclone's root +directory (the |root/directory| in |onedrive:root/directory|) then +using this flag will be be a big performance win. If your data is +mostly not under the root then using this flag will be a big +performance loss. + +It is recommended if you are mounting your onedrive at the root +(or near the root when using crypt) and using rclone |rc vfs/refresh|. +`, "|", "`"), + Advanced: true, }, { Name: config.ConfigEncoding, Help: config.ConfigEncodingHelp, @@ -645,6 +676,7 @@ type Options struct { LinkPassword string `config:"link_password"` HashType string `config:"hash_type"` AVOverride bool `config:"av_override"` + Delta bool `config:"delta"` Enc encoder.MultiEncoder `config:"encoding"` } @@ -976,6 +1008,11 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e f.dirCache = dircache.New(root, rootID, f) + // ListR only supported if delta set + if !f.opt.Delta { + f.features.ListR = nil + } + // Find the current root err = f.dirCache.FindRoot(ctx, false) if err != nil { diff --git a/docs/content/onedrive.md b/docs/content/onedrive.md index da83f448a..a57db0764 100644 --- a/docs/content/onedrive.md +++ b/docs/content/onedrive.md @@ -189,6 +189,9 @@ This remote supports `--fast-list` which allows you to use fewer transactions in exchange for more memory. See the [rclone docs](/docs/#fast-list) for more details. +This must be enabled with the `--onedrive-delta` flag (or `delta = +true` in the config file) as it can cause performance degradation. + It does this by using the delta listing facilities of OneDrive which returns all the files in the remote very efficiently. This is much more efficient than listing directories recursively and is Microsoft's diff --git a/docs/content/overview.md b/docs/content/overview.md index d3dffb083..7a05c3912 100644 --- a/docs/content/overview.md +++ b/docs/content/overview.md @@ -493,7 +493,7 @@ upon backend-specific capabilities. | Memory | No | Yes | No | No | No | Yes | Yes | No | No | No | No | | Microsoft Azure Blob Storage | Yes | Yes | No | No | No | Yes | Yes | Yes | No | No | No | | Microsoft Azure Files Storage | No | Yes | Yes | Yes | No | No | Yes | Yes | No | Yes | Yes | -| Microsoft OneDrive | Yes | Yes | Yes | Yes | Yes | Yes | No | No | Yes | Yes | Yes | +| Microsoft OneDrive | Yes | Yes | Yes | Yes | Yes | Yes ⁵ | No | No | Yes | Yes | Yes | | OpenDrive | Yes | Yes | Yes | Yes | No | No | No | No | No | No | Yes | | OpenStack Swift | Yes ¹ | Yes | No | No | No | Yes | Yes | No | No | Yes | No | | Oracle Object Storage | No | Yes | No | No | Yes | Yes | Yes | Yes | No | No | No | @@ -527,6 +527,8 @@ purging a directory inside a bucket, files are deleted individually. ⁴ Use the `--sftp-copy-is-hardlink` flag to enable. +⁵ Use the `--onedrive-delta` flag to enable. + ### Purge ### This deletes a directory quicker than just deleting all the files in