If file attribs are specified set them even if file already exists.

Fixes #11821
pull/18777/head
Toshio Kuratomi 9 years ago committed by Matt Clay
parent 72d3aab736
commit 4c9f9973dd

@ -253,7 +253,6 @@ def extract_filename_from_headers(headers):
# main # main
def main(): def main():
argument_spec = url_argument_spec() argument_spec = url_argument_spec()
argument_spec.update( argument_spec.update(
url = dict(required=True), url = dict(required=True),
@ -310,7 +309,6 @@ def main():
except ValueError: except ValueError:
module.fail_json(msg="The checksum parameter has to be in format <algorithm>:<checksum>") module.fail_json(msg="The checksum parameter has to be in format <algorithm>:<checksum>")
if not dest_is_dir and os.path.exists(dest): if not dest_is_dir and os.path.exists(dest):
checksum_mismatch = False checksum_mismatch = False
@ -326,7 +324,15 @@ def main():
# Not forcing redownload, unless checksum does not match # Not forcing redownload, unless checksum does not match
if not force and not checksum_mismatch: if not force and not checksum_mismatch:
module.exit_json(msg="file already exists", dest=dest, url=url, changed=False) # allow file attribute changes
module.params['path'] = dest
file_args = module.load_file_common_arguments(module.params)
file_args['path'] = dest
changed = module.set_fs_attributes_if_different(file_args, False)
if changed:
module.exit_json(msg="file already exists but file attributes changed", dest=dest, url=url, changed=changed)
module.exit_json(msg="file already exists", dest=dest, url=url, changed=changed)
# If the file already exists, prepare the last modified time for the # If the file already exists, prepare the last modified time for the
# request. # request.

Loading…
Cancel
Save