From 7c0645dda9cfb15e50d358dd1c1d00d67a94fdd0 Mon Sep 17 00:00:00 2001 From: Bill Fraser Date: Fri, 3 May 2024 10:55:50 -0700 Subject: [PATCH] dropbox: add option to override root namespace This lets you, for example, use shared folders without mounting them into your home namespace first, as long as you know their namespace ID. (The --dropbox-shared-folders flag could thus be changed to not need to mount the shared folder first, but I'm not doing that here as it's a behavior change, who knows, maybe somebody relies on it.) --- backend/dropbox/dropbox.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/backend/dropbox/dropbox.go b/backend/dropbox/dropbox.go index bd4f28c05..28eaa30be 100644 --- a/backend/dropbox/dropbox.go +++ b/backend/dropbox/dropbox.go @@ -216,7 +216,10 @@ are supported. Note that we don't unmount the shared folder afterwards so the --dropbox-shared-folders can be omitted after the first use of a particular -shared folder.`, +shared folder. + +See also --dropbox-root-namespace for an alternative way to work with shared +folders.`, Default: false, Advanced: true, }, { @@ -237,6 +240,11 @@ shared folder.`, encoder.EncodeDel | encoder.EncodeRightSpace | encoder.EncodeInvalidUtf8, + }, { + Name: "root_namespace", + Help: "Specify a different Dropbox namespace ID to use as the root for all paths.", + Default: "", + Advanced: true, }}...), defaultBatcherOptions.FsOptions("For full info see [the main docs](https://rclone.org/dropbox/#batch-mode)\n\n")...), }) } @@ -253,6 +261,7 @@ type Options struct { AsyncBatch bool `config:"async_batch"` PacerMinSleep fs.Duration `config:"pacer_min_sleep"` Enc encoder.MultiEncoder `config:"encoding"` + RootNsid string `config:"root_namespace"` } // Fs represents a remote dropbox server @@ -502,8 +511,11 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e f.features.Fill(ctx, f) - // If root starts with / then use the actual root - if strings.HasPrefix(root, "/") { + if f.opt.RootNsid != "" { + f.ns = f.opt.RootNsid + fs.Debugf(f, "Overriding root namespace to %q", f.ns) + } else if strings.HasPrefix(root, "/") { + // If root starts with / then use the actual root var acc *users.FullAccount err = f.pacer.Call(func() (bool, error) { acc, err = f.users.GetCurrentAccount()