From 24ec381dda1bee53a64e8178aacbc4c0b7757a92 Mon Sep 17 00:00:00 2001
From: David Stainton <dstainton415@gmail.com>
Date: Wed, 26 Aug 2015 22:02:26 +0200
Subject: [PATCH] Fix replace_file; rename only if replaced_path exists

---
 src/allmydata/util/fileutil.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/allmydata/util/fileutil.py b/src/allmydata/util/fileutil.py
index 5461319d..16dda5c0 100644
--- a/src/allmydata/util/fileutil.py
+++ b/src/allmydata/util/fileutil.py
@@ -619,13 +619,12 @@ else:
         if not os.path.exists(replacement_path):
             raise ConflictError("Replacement file not found: %r" % (replacement_path,))
         try:
-            os.rename(replaced_path, backup_path)
+            if os.path.exists(replaced_path):
+                os.rename(replaced_path, backup_path)
             rename_no_overwrite(replacement_path, replaced_path)
         except EnvironmentError:
-            print "@@@@@@@@@@@@@@@@@@@@@@@@@@@env err"
             reraise(ConflictError)
 
-
 PathInfo = namedtuple('PathInfo', 'isdir isfile islink exists size ctime mtime')
 
 def get_pathinfo(path_u):
-- 
2.45.2