From 22461e335a68af1bb6bf43f63231c5dd7c0aa0b1 Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Fri, 24 Jul 2015 09:38:11 -0400 Subject: [PATCH] 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. --- cloud/amazon/s3.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/cloud/amazon/s3.py b/cloud/amazon/s3.py index e6b511b36b8..ecc2a9dc69e 100644 --- a/cloud/amazon/s3.py +++ b/cloud/amazon/s3.py @@ -472,10 +472,10 @@ def main(): else: 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) - if pathrtn is False: - download_s3file(module, s3, bucket, obj, dest, retries, version=version) + if pathrtn is False or overwrite == 'always': + download_s3file(module, s3, bucket, obj, dest) # Compare the remote MD5 sum of the object with the local dest md5sum, if it already exists. if pathrtn is True: @@ -499,10 +499,6 @@ def main(): if sum_matches is True and overwrite == 'never': 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 mode == 'put':