From d71b9bae893e5cb860eb7717af93d00363b3890c Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Sun, 20 Mar 2016 07:34:59 -0700 Subject: [PATCH] If file attribs are specified set them even if file already exists. Fixes #11821 --- network/basics/get_url.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/network/basics/get_url.py b/network/basics/get_url.py index 87d0573e379..e762a7c69e6 100644 --- a/network/basics/get_url.py +++ b/network/basics/get_url.py @@ -254,7 +254,6 @@ def extract_filename_from_headers(headers): # main def main(): - argument_spec = url_argument_spec() argument_spec.update( url = dict(required=True), @@ -311,7 +310,6 @@ def main(): except ValueError: module.fail_json(msg="The checksum parameter has to be in format :") - if not dest_is_dir and os.path.exists(dest): checksum_mismatch = False @@ -327,7 +325,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.