From d163deaf4509a8d6401a1ba7cd4374a9dd69894c Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Sun, 5 May 2013 13:26:29 -0400 Subject: [PATCH] generalized cleanup function, in case modules want to use removed return code as it doesn't make sense anymore Signed-off-by: Brian Coca --- files/copy | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/files/copy b/files/copy index 26c05f7d7cf..c1da485751c 100644 --- a/files/copy +++ b/files/copy @@ -147,11 +147,7 @@ def main(): (rc,out,err) = module.run_command(validate % src) if rc != 0: module.fail_json(msg="failed to validate: rc:%s error:%s" % (rc,err)) - if not module.atomic_move(src, dest): - try: - os.unlink(src) # cleanup tmp files on failure - except OSError, e: - sys.stderr.write("failed to clean up tmp file %s: %s\n" % (src, e)) + module.atomic_move(src, dest): except IOError: module.fail_json(msg="failed to copy: %s to %s" % (src, dest)) changed = True