From 53aa4b87fd3c1ae8a96c83d0d73bb9131df1e1c1 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Tue, 9 Feb 2021 09:58:44 +0000 Subject: [PATCH] b2: fix failed to create file system with application key limited to a prefix Before this change, if an application key limited to a prefix was in use, with trailing `/` marking the folders then rclone would HEAD the path without a trailing `/` to work out if it was a file or a folder. This returned a permission denied error, which rclone returned to the user. Failed to create file system for "b2:bucket/path/": failed to HEAD for download: Unknown 401 (401 unknown) This change assumes any errors on HEAD will make rclone assume the object does not exist and the path is referring to a directory. See: https://forum.rclone.org/t/b2-error-on-application-key-limited-to-a-prefix/22159/ --- backend/b2/b2.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/backend/b2/b2.go b/backend/b2/b2.go index 307a45ea8..a6f45bf13 100644 --- a/backend/b2/b2.go +++ b/backend/b2/b2.go @@ -479,12 +479,9 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e f.setRoot(newRoot) _, err := f.NewObject(ctx, leaf) if err != nil { - if err == fs.ErrorObjectNotFound { - // File doesn't exist so return old f - f.setRoot(oldRoot) - return f, nil - } - return nil, err + // File doesn't exist so return old f + f.setRoot(oldRoot) + return f, nil } // return an error with an fs which points to the parent return f, fs.ErrorIsFile