From 588b129018cd61eb1459b7908bf148b6272a1276 Mon Sep 17 00:00:00 2001 From: Seth Vidal Date: Thu, 9 Aug 2012 15:33:05 -0400 Subject: [PATCH] fix case where destination does not yet exist - no backup can be made --- library/copy | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/library/copy b/library/copy index a6c2efef68e..be7e685a8ab 100755 --- a/library/copy +++ b/library/copy @@ -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))