From 5b5af14921d26396dd152bf53270dd49e563d4e4 Mon Sep 17 00:00:00 2001 From: Steve Smith Date: Thu, 20 Mar 2014 13:14:24 +0100 Subject: [PATCH] Only unlink the symlink tempfile on error if it was created in the previous operation. --- files/file | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/files/file b/files/file index b1c57ff4d97..710a9224c13 100644 --- a/files/file +++ b/files/file @@ -305,7 +305,8 @@ def main(): os.symlink(src, tmppath) os.rename(tmppath, path) except OSError, e: - os.unlink(tmppath) + if os.path.exists(tmppath): + os.unlink(tmppath) module.fail_json(path=path, msg='Error while replacing: %s' % str(e)) try: if state == 'hard':