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

Fixes #11821
This commit is contained in:
Toshio Kuratomi 2016-03-20 07:34:59 -07:00 committed by Matt Clay
parent 72d3aab736
commit 4c9f9973dd

View file

@ -253,7 +253,6 @@ def extract_filename_from_headers(headers):
# main
def main():
argument_spec = url_argument_spec()
argument_spec.update(
url = dict(required=True),
@ -310,7 +309,6 @@ def main():
except ValueError:
module.fail_json(msg="The checksum parameter has to be in format <algorithm>:<checksum>")
if not dest_is_dir and os.path.exists(dest):
checksum_mismatch = False
@ -326,7 +324,15 @@ def main():
# Not forcing redownload, unless checksum does not match
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
# request.