From b6e86b2c7fc18dbd905d830746a6716aca7b8f26 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Tue, 7 Jan 2020 19:23:08 +0000 Subject: [PATCH] s3: fix missing x-amz-meta-md5chksum headers for multipart uploads This reverts "s3: fix DisableChecksum condition" which introduced the problem. This reverts commit c05bb63f9679e09ecb078e7477f3efd02846c2ad. The code was correct as it stands - the comment was incorrect and this commit updates it. See: https://forum.rclone.org/t/s3-upload-md5-check-sum/13706 --- backend/s3/s3.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/backend/s3/s3.go b/backend/s3/s3.go index 6bd950f91..e87e2cb08 100644 --- a/backend/s3/s3.go +++ b/backend/s3/s3.go @@ -2240,10 +2240,13 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op metaMtime: aws.String(swift.TimeToFloatString(modTime)), } - // read the md5sum if available for non multpart and if - // disable checksum isn't present. + // read the md5sum if available + // - for non multpart + // - so we can add a ContentMD5 + // - for multipart provided checksums aren't disabled + // - so we can add the md5sum in the metadata as metaMD5Hash var md5sum string - if !multipart && !o.fs.opt.DisableChecksum { + if !multipart || !o.fs.opt.DisableChecksum { hash, err := src.Hash(ctx, hash.MD5) if err == nil && matchMd5.MatchString(hash) { hashBytes, err := hex.DecodeString(hash)