]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Fix replace_file; rename only if replaced_path exists
authorDavid Stainton <dstainton415@gmail.com>
Wed, 26 Aug 2015 20:02:26 +0000 (22:02 +0200)
committerDavid Stainton <dstainton415@gmail.com>
Wed, 26 Aug 2015 20:02:26 +0000 (22:02 +0200)
src/allmydata/util/fileutil.py

index 5461319db9fd2b4e318a75eb1cb076da5a1ac835..16dda5c0ec3ecc1b193f09204d13fe4f3984a690 100644 (file)
@@ -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):