4006: return s3 url even if file exists

pull/4413/head
James Tanner 11 years ago
parent 948d019fef
commit 9c3fb9c2b7

@ -231,12 +231,12 @@ def download_s3str(module, s3, bucket, obj):
except s3.provider.storage_copy_error, e: except s3.provider.storage_copy_error, e:
module.fail_json(msg= str(e)) module.fail_json(msg= str(e))
def get_download_url(module, s3, bucket, obj, expiry): def get_download_url(module, s3, bucket, obj, expiry, changed=True):
try: try:
bucket = s3.lookup(bucket) bucket = s3.lookup(bucket)
key = bucket.lookup(obj) key = bucket.lookup(obj)
url = key.generate_url(expiry) url = key.generate_url(expiry)
module.exit_json(msg="Download url:", url=url, expiry=expiry, changed=True) module.exit_json(msg="Download url:", url=url, expiry=expiry, changed=changed)
sys.exit(0) sys.exit(0)
except s3.provider.storage_response_error, e: except s3.provider.storage_response_error, e:
module.fail_json(msg= str(e)) module.fail_json(msg= str(e))
@ -378,7 +378,7 @@ def main():
if overwrite is True: if overwrite is True:
upload_s3file(module, s3, bucket, obj, src, expiry) upload_s3file(module, s3, bucket, obj, src, expiry)
else: else:
module.exit_json(msg="Local and remote object are identical, ignoring. Use overwrite parameter to force.", changed=False) get_download_url(module, s3, bucket, obj, expiry, changed=False) ## PATCH
else: else:
sum_matches = False sum_matches = False
if overwrite is True: if overwrite is True:

Loading…
Cancel
Save