mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 21:00:22 -07:00
fix issue [ get_url does not change mode when checksum matches ] (#43342)
* fix #29614 * add change log for #43342 * Cleanup tests and add tests for this scenario Co-authored-by: ptux
This commit is contained in:
parent
e0e6fe5cf7
commit
68683b4c73
3 changed files with 61 additions and 34 deletions
|
@ -451,22 +451,18 @@ def main():
|
|||
destination_checksum = module.digest_from_file(dest, algorithm)
|
||||
|
||||
if checksum == destination_checksum:
|
||||
module.exit_json(msg="file already exists", dest=dest, url=url, changed=False)
|
||||
# Not forcing redownload, unless checksum does not match
|
||||
# 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)
|
||||
|
||||
checksum_mismatch = True
|
||||
|
||||
# Not forcing redownload, unless checksum does not match
|
||||
if not force and not checksum_mismatch:
|
||||
# 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.
|
||||
mtime = os.path.getmtime(dest)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue