From caa2b8bf40f185d176eb4e10c2c03670014487a5 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Tue, 9 Nov 2021 10:10:44 +0000 Subject: [PATCH] dropbox: save an API request when at the root Before this change, rclone always emitted an API request to discover what type of thing the root is. This is unecessary as it is always a directory. --- backend/dropbox/dropbox.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/backend/dropbox/dropbox.go b/backend/dropbox/dropbox.go index 11436a327..956f6bde1 100644 --- a/backend/dropbox/dropbox.go +++ b/backend/dropbox/dropbox.go @@ -566,15 +566,17 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e f.setRoot(root) // See if the root is actually an object - _, err = f.getFileMetadata(ctx, f.slashRoot) - if err == nil { - newRoot := path.Dir(f.root) - if newRoot == "." { - newRoot = "" + if f.root != "" { + _, err = f.getFileMetadata(ctx, f.slashRoot) + if err == nil { + newRoot := path.Dir(f.root) + if newRoot == "." { + newRoot = "" + } + f.setRoot(newRoot) + // return an error with an fs which points to the parent + return f, fs.ErrorIsFile } - f.setRoot(newRoot) - // return an error with an fs which points to the parent - return f, fs.ErrorIsFile } return f, nil }