Skip to content

Commit

Permalink
fix case where destination does not yet exist - no backup can be made
Browse files Browse the repository at this point in the history
  • Loading branch information
skvidal committed Aug 9, 2012
1 parent 28e9b11 commit 588b129
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions library/copy
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,12 @@ def main():
if md5sum_src != md5sum_dest:
try:
if backup:
success, msg = backuplocal(dest)
if not success:
module.fail_jason(msg=msg)
else:
backup_file = msg
if os.path.exists(dest):
success, msg = backuplocal(dest)
if not success:
module.fail_jason(msg=msg)
else:
backup_file = msg
shutil.copyfile(src, dest)
except shutil.Error:
module.fail_json(msg="failed to copy: %s and %s are the same" % (src, dest))
Expand Down

0 comments on commit 588b129

Please sign in to comment.