From 723c1dfdc52b99b4412303b2d4e5f4c3502947f2 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Tue, 2 Jun 2020 14:29:42 +0100 Subject: [PATCH] s3: fix upload of single files into buckets without create permission Before this change, attempting to upload a single file into an s3 bucket which did not have create permission gave AccessDenied: Access Denied error when it tried to create the bucket. This was masked until e2bf91452a263ff8babb3e5e153a2d2c7b4b3719 was fixed. This fix marks the bucket as OK if a fetch on an object indicates it is OK. This stops rclone thinking it has to create the bucket in the first place. Fixes #4297 --- backend/s3/s3.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/s3/s3.go b/backend/s3/s3.go index 0ce6f14ed..c6201492c 100644 --- a/backend/s3/s3.go +++ b/backend/s3/s3.go @@ -2033,11 +2033,17 @@ func (o *Object) readMetaData(ctx context.Context) (err error) { if err != nil { if awsErr, ok := err.(awserr.RequestFailure); ok { if awsErr.StatusCode() == http.StatusNotFound { + // NotFound indicates bucket was OK + // NoSuchBucket would be returned if bucket was bad + if awsErr.Code() == "NotFound" { + o.fs.cache.MarkOK(bucket) + } return fs.ErrorObjectNotFound } } return err } + o.fs.cache.MarkOK(bucket) var size int64 // Ignore missing Content-Length assuming it is 0 // Some versions of ceph do this due their apache proxies