If overwrite is set, download eagerly.

If the we are going to overwrite the file anyway,
there is no need to do any checksums locally or
grab the remote etag.
This commit is contained in:
Feanil Patel 2015-07-24 09:38:11 -04:00 committed by Matt Clay
parent 950701ba3e
commit e4898a4348

View file

@ -482,10 +482,10 @@ def main():
else: else:
module.fail_json(msg="Key %s does not exist."%obj, failed=True) module.fail_json(msg="Key %s does not exist."%obj, failed=True)
# If the destination path doesn't exist, no need to md5um etag check, so just download. # If the destination path doesn't exist or overwrite is True, no need to do the md5um etag check, so just download.
pathrtn = path_check(dest) pathrtn = path_check(dest)
if pathrtn is False: if pathrtn is False or overwrite == 'always':
download_s3file(module, s3, bucket, obj, dest, retries, version=version) download_s3file(module, s3, bucket, obj, dest)
# Compare the remote MD5 sum of the object with the local dest md5sum, if it already exists. # Compare the remote MD5 sum of the object with the local dest md5sum, if it already exists.
if pathrtn is True: if pathrtn is True:
@ -509,10 +509,6 @@ def main():
if sum_matches is True and overwrite is False: if sum_matches is True and overwrite is False:
module.exit_json(msg="Local and remote object are identical, ignoring. Use overwrite parameter to force.", changed=False) module.exit_json(msg="Local and remote object are identical, ignoring. Use overwrite parameter to force.", changed=False)
# At this point explicitly define the overwrite condition.
if sum_matches is True and pathrtn is True and overwrite == 'always':
download_s3file(module, s3, bucket, obj, dest, retries, version=version)
# if our mode is a PUT operation (upload), go through the procedure as appropriate ... # if our mode is a PUT operation (upload), go through the procedure as appropriate ...
if mode == 'put': if mode == 'put':