1
0
mirror of https://github.com/rclone/rclone.git synced 2025-01-19 04:47:54 +02:00

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
This commit is contained in:
Nick Craig-Wood 2020-01-07 19:23:08 +00:00
parent 4453fa4ba6
commit b6e86b2c7f

View File

@ -2240,10 +2240,13 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op
metaMtime: aws.String(swift.TimeToFloatString(modTime)), metaMtime: aws.String(swift.TimeToFloatString(modTime)),
} }
// read the md5sum if available for non multpart and if // read the md5sum if available
// disable checksum isn't present. // - 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 var md5sum string
if !multipart && !o.fs.opt.DisableChecksum { if !multipart || !o.fs.opt.DisableChecksum {
hash, err := src.Hash(ctx, hash.MD5) hash, err := src.Hash(ctx, hash.MD5)
if err == nil && matchMd5.MatchString(hash) { if err == nil && matchMd5.MatchString(hash) {
hashBytes, err := hex.DecodeString(hash) hashBytes, err := hex.DecodeString(hash)