From 01877e5a0fc0ccfe36316435bed836845ec78a93 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Fri, 16 Dec 2022 11:44:58 +0000 Subject: [PATCH] s3: ignore versionIDs from uploads unless using --s3-versions or --s3-versions-at Before this change, when a new object was created s3 returns its versionID (on a versioned bucket) and rclone recorded it in the object. This means that when rclone came to delete the object it would delete it with the versionID. However it is common to forbid actions with versionIDs on buckets so as to preserve the historical record and these operations would fail whereas they succeeded in pre-v1.60.0 versions. This patch fixes the problem by not recording versions of objects supplied by the S3 API on upload unless `--s3-versions` or `--s3-version-at` is used. This makes rclone behave as it did before v1.60.0 when version support was introduced. See: https://forum.rclone.org/t/s3-and-intermittent-403-errors-with-file-renames-and-drag-and-drop-operations-in-windows-explorer/34773 --- backend/s3/s3.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/s3/s3.go b/backend/s3/s3.go index 8d4a4c5f0..c6977b8c9 100644 --- a/backend/s3/s3.go +++ b/backend/s3/s3.go @@ -5507,7 +5507,12 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op if err != nil { return err } - o.versionID = versionID + // Only record versionID if we are using --s3-versions or --s3-version-at + if o.fs.opt.Versions || o.fs.opt.VersionAt.IsSet() { + o.versionID = versionID + } else { + o.versionID = nil + } // User requested we don't HEAD the object after uploading it // so make up the object as best we can assuming it got