Skip to content

Commit 38ba00c

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 3eb5a52 commit 38ba00c

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
@@ -162,6 +162,7 @@ class Config(object):
162162
# expected for every send file requests.
163163
use_http_expect = False
164164
signurl_use_https = False
165+
put_check_etag = True
165166

166167
## Creating a singleton
167168
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
@@ -1543,7 +1543,7 @@ def send_file(self, request, stream, labels, buffer = '', throttle = 0,
15431543
debug("MD5 sums: computed=%s, received=%s" % (md5_computed, response["headers"].get('etag', '').strip('"\'')))
15441544
## when using KMS encryption, MD5 etag value will not match
15451545
md5_from_s3 = response["headers"].get("etag", "").strip('"\'')
1546-
if ('-' not in md5_from_s3) and (md5_from_s3 != md5_hash.hexdigest()) and response["headers"].get("x-amz-server-side-encryption") != 'aws:kms':
1546+
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':
15471547
warning("MD5 Sums don't match!")
15481548
if retries:
15491549
warning("Retrying upload of %s" % (filename))
@@ -1770,7 +1770,7 @@ def recv_file(self, request, stream, labels, start_position = 0, retries = _max_
17701770
start_position + int(response["headers"]["content-length"]), response["size"]))
17711771
debug("ReceiveFile: Computed MD5 = %s" % response.get("md5"))
17721772
# avoid ETags from multipart uploads that aren't the real md5
1773-
if ('-' not in md5_from_s3 and not response["md5match"]) and (response["headers"].get("x-amz-server-side-encryption") != 'aws:kms'):
1773+
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'):
17741774
warning("MD5 signatures do not match: computed=%s, received=%s" % (
17751775
response.get("md5"), md5_from_s3))
17761776
return response

s3cmd

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

28332833
## Process --(no-)check-md5
28342834
if options.check_md5 == False:
2835+
cfg.put_check_etag = False
28352836
try:
28362837
cfg.sync_checks.remove("md5")
28372838
cfg.preserve_attrs_list.remove("md5")
28382839
except Exception:
28392840
pass
28402841
if options.check_md5 == True:
2842+
cfg.put_check_etag = True
28412843
if cfg.sync_checks.count("md5") == 0:
28422844
cfg.sync_checks.append("md5")
28432845
if cfg.preserve_attrs_list.count("md5") == 0:

0 commit comments

Comments
 (0)