From a8db0be8916a378e75f43b7abe93c12cde72230a Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Thu, 11 Jun 2020 11:28:39 +0100 Subject: [PATCH] s3: fix KS3 problem where multipart uploads have valid md5sums as Etags KS3 appears to return an Etag which is a valid MD5SUM for multipart uploads. This confuses rclone which is expecting an invalid MD5SUM here. This patch works around that by clearing the Etag on the object returned from a multipart upload if it matches a valid MD5SUM. --- backend/s3/s3.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/s3/s3.go b/backend/s3/s3.go index 4cbf6fa0f..8510ea4fe 100644 --- a/backend/s3/s3.go +++ b/backend/s3/s3.go @@ -3202,6 +3202,12 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op // Read the metadata from the newly created object o.meta = nil // wipe old metadata err = o.readMetaData(ctx) + // Empty an Etag which is a valid md5sum for multipart + // uploads. This works around a bug in KS3 where the ETag is a + // correctly formed md5sum for multpart uploads + if multipart && matchMd5.MatchString(strings.Trim(strings.ToLower(o.etag), `"`)) { + o.etag = "" + } return err }