From b029fb591fb97957c00086a4ebe207a416d050c1 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Mon, 8 Feb 2021 13:22:12 +0000 Subject: [PATCH] s3: fix failed to create file system with folder level permissions policy Before this change, if folder level access permissions policy 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 "s3:bucket/path/": Forbidden: Forbidden status code: 403, request id: XXXX, host id: Previous to this change 53aa03cc44b2a425 s3: complete sse-c implementation rclone would assume any errors when HEAD-ing the object implied it didn't exist and this test would not fail. This change reverts the functionality of the test to work as it did before, meaning any errors on HEAD will make rclone assume the object does not exist and the path is referring to a directory. Fixes #4990 --- backend/s3/s3.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/backend/s3/s3.go b/backend/s3/s3.go index e230fc6d8..f468a5147 100644 --- a/backend/s3/s3.go +++ b/backend/s3/s3.go @@ -1694,12 +1694,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 || err == fs.ErrorNotAFile { - // File doesn't exist or is a directory so return old f - f.setRoot(oldRoot) - return f, nil - } - return nil, err + // File doesn't exist or is a directory 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