mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 06:12:51 +00:00
fix case where destination does not yet exist - no backup can be made
This commit is contained in:
11
library/copy
11
library/copy
@@ -75,11 +75,12 @@ def main():
|
|||||||
if md5sum_src != md5sum_dest:
|
if md5sum_src != md5sum_dest:
|
||||||
try:
|
try:
|
||||||
if backup:
|
if backup:
|
||||||
success, msg = backuplocal(dest)
|
if os.path.exists(dest):
|
||||||
if not success:
|
success, msg = backuplocal(dest)
|
||||||
module.fail_jason(msg=msg)
|
if not success:
|
||||||
else:
|
module.fail_jason(msg=msg)
|
||||||
backup_file = msg
|
else:
|
||||||
|
backup_file = msg
|
||||||
shutil.copyfile(src, dest)
|
shutil.copyfile(src, dest)
|
||||||
except shutil.Error:
|
except shutil.Error:
|
||||||
module.fail_json(msg="failed to copy: %s and %s are the same" % (src, dest))
|
module.fail_json(msg="failed to copy: %s and %s are the same" % (src, dest))
|
||||||
|
|||||||
Reference in New Issue
Block a user