1
mirror of https://github.com/rclone/rclone synced 2024-11-27 05:23:40 +01:00

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/
This commit is contained in:
Nick Craig-Wood 2021-02-09 09:58:44 +00:00
parent edfe183ba2
commit 53aa4b87fd

View File

@ -479,12 +479,9 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e
f.setRoot(newRoot) f.setRoot(newRoot)
_, err := f.NewObject(ctx, leaf) _, err := f.NewObject(ctx, leaf)
if err != nil { if err != nil {
if err == fs.ErrorObjectNotFound { // File doesn't exist so return old f
// File doesn't exist so return old f f.setRoot(oldRoot)
f.setRoot(oldRoot) return f, nil
return f, nil
}
return nil, err
} }
// return an error with an fs which points to the parent // return an error with an fs which points to the parent
return f, fs.ErrorIsFile return f, fs.ErrorIsFile