Fix lint, simplify if statement.
@@ -839,6 +839,8 @@ class BaseS3StorageDriver(StorageDriver):
server_hash = headers.get('etag', '').replace('"', '')
server_side_encryption = headers.get('x-amz-server-side-encryption',
None)
+ aws_kms_encryption = (server_side_encryption == 'aws:kms')
+ hash_matches = (result_dict['data_hash'] == server_hash)
# NOTE: If AWS KMS server side encryption is enabled, ETag won't
# contain object MD5 digest so we skip the checksum check
@@ -846,8 +848,7 @@ class BaseS3StorageDriver(StorageDriver):
# /RESTCommonResponseHeaders.html
# and https://github.com/apache/libcloud/issues/1401
# for details
- if server_side_encryption != 'aws:kms' and (verify_hash and
- result_dict['data_hash'] != server_hash):
+ if verify_hash and not aws_kms_encryption and not hash_matches:
raise ObjectHashMismatchError(
value='MD5 hash {0} checksum does not match {1}'.format(
server_hash, result_dict['data_hash']),
