From cf2c2792e62beda08821578f041bab3bfe81d7a8 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Fri, 29 Oct 2021 10:23:41 +0100 Subject: [PATCH] s3: fix corrupted on transfer: sizes differ 0 vs xxxx with Ceph In this commit, released in 1.56.0 we started reading the size of the object from the Content-Length header as returned by the GET request to read the object. 4401d180aabe5047 s3: add --s3-no-head-object However some object storage systems, notably Ceph, don't return a Content-Length header. The new code correctly calls the setMetaData function with a nil pointer to the ContentLength. However due to this commit from 2014, released in v1.18, the setMetaData function was not ignoring the size as it should have done. 0da6f242217aae7a s3: use official github.com/aws/aws-sdk-go including multipart upload #101 This commit correctly ignores the content length if not set. Fixes #5732 --- backend/s3/s3.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/backend/s3/s3.go b/backend/s3/s3.go index 653dcfaae..b65fc086b 100644 --- a/backend/s3/s3.go +++ b/backend/s3/s3.go @@ -2892,14 +2892,12 @@ func (o *Object) readMetaData(ctx context.Context) (err error) { } func (o *Object) setMetaData(etag *string, contentLength *int64, lastModified *time.Time, meta map[string]*string, mimeType *string, storageClass *string) { - var size int64 // Ignore missing Content-Length assuming it is 0 // Some versions of ceph do this due their apache proxies if contentLength != nil { - size = *contentLength + o.bytes = *contentLength } o.setMD5FromEtag(aws.StringValue(etag)) - o.bytes = size o.meta = meta if o.meta == nil { o.meta = map[string]*string{}