Skip to content

Commit f48d0a0

Browse files
committed
Add config to avoid checking MD5 on get and put
Overload existing --no-check-md5. Object stores like S3Proxy cannot return an MD5 ETag using some providers: * Atmos returns nothing * Azure returns an opaque ETag * B2 returns a SHA1
1 parent ae6cdde commit f48d0a0

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

S3/Config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ class Config(object):
206206
# s3 will timeout if a request/transfer is stuck for more than a short time
207207
throttle_max = 100
208208
public_url_use_https = False
209+
put_check_etag = True
209210

210211
## Creating a singleton
211212
def __new__(self, configfile = None, access_key=None, secret_key=None, access_token=None):

S3/S3.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,7 +1583,7 @@ def send_file(self, request, stream, labels, buffer = '', throttle = 0,
15831583
debug("MD5 sums: computed=%s, received=%s" % (md5_computed, response["headers"].get('etag', '').strip('"\'')))
15841584
## when using KMS encryption, MD5 etag value will not match
15851585
md5_from_s3 = response["headers"].get("etag", "").strip('"\'')
1586-
if ('-' not in md5_from_s3) and (md5_from_s3 != md5_hash.hexdigest()) and response["headers"].get("x-amz-server-side-encryption") != 'aws:kms':
1586+
if self.config.put_check_etag and ('-' not in md5_from_s3) and (md5_from_s3 != md5_hash.hexdigest()) and response["headers"].get("x-amz-server-side-encryption") != 'aws:kms':
15871587
warning("MD5 Sums don't match!")
15881588
if retries:
15891589
warning("Retrying upload of %s" % (filename))
@@ -1821,7 +1821,7 @@ def recv_file(self, request, stream, labels, start_position = 0, retries = _max_
18211821
start_position + int(response["headers"]["content-length"]), response["size"]))
18221822
debug("ReceiveFile: Computed MD5 = %s" % response.get("md5"))
18231823
# avoid ETags from multipart uploads that aren't the real md5
1824-
if ('-' not in md5_from_s3 and not response["md5match"]) and (response["headers"].get("x-amz-server-side-encryption") != 'aws:kms'):
1824+
if self.config.put_check_etag and ('-' not in md5_from_s3 and not response["md5match"]) and (response["headers"].get("x-amz-server-side-encryption") != 'aws:kms'):
18251825
warning("MD5 signatures do not match: computed=%s, received=%s" % (
18261826
response.get("md5"), md5_from_s3))
18271827
return response

s3cmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2856,12 +2856,14 @@ def main():
28562856

28572857
## Process --(no-)check-md5
28582858
if options.check_md5 == False:
2859+
cfg.put_check_etag = False
28592860
try:
28602861
cfg.sync_checks.remove("md5")
28612862
cfg.preserve_attrs_list.remove("md5")
28622863
except Exception:
28632864
pass
28642865
if options.check_md5 == True:
2866+
cfg.put_check_etag = True
28652867
if cfg.sync_checks.count("md5") == 0:
28662868
cfg.sync_checks.append("md5")
28672869
if cfg.preserve_attrs_list.count("md5") == 0:

0 commit comments

Comments
 (0)