mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-01 05:49:09 -07:00
Fix logic to not re-download existing files when force=no (#45495)
* Fix logic to not re-download existing files when force=no. Fixes #45491 * Reduce logic complexity
This commit is contained in:
parent
b22b07e300
commit
5785de582f
3 changed files with 27 additions and 12 deletions
|
@ -482,18 +482,20 @@ def main():
|
|||
if not force and checksum != '':
|
||||
destination_checksum = module.digest_from_file(dest, algorithm)
|
||||
|
||||
if checksum == destination_checksum:
|
||||
# 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
|
||||
result['changed'] = module.set_fs_attributes_if_different(file_args, False)
|
||||
if result['changed']:
|
||||
module.exit_json(msg="file already exists but file attributes changed", **result)
|
||||
module.exit_json(msg="file already exists", **result)
|
||||
if checksum != destination_checksum:
|
||||
checksum_mismatch = True
|
||||
|
||||
checksum_mismatch = True
|
||||
# Not forcing redownload, unless checksum does not match
|
||||
if not force and not checksum_mismatch:
|
||||
# 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
|
||||
result['changed'] = module.set_fs_attributes_if_different(file_args, False)
|
||||
if result['changed']:
|
||||
module.exit_json(msg="file already exists but file attributes changed", **result)
|
||||
module.exit_json(msg="file already exists", **result)
|
||||
|
||||
# If the file already exists, prepare the last modified time for the
|
||||
# request.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue