replace_file should not fail if replaced_path does not exist.
authorDaira Hopwood <daira@jacaranda.org>
Tue, 15 Sep 2015 17:31:20 +0000 (18:31 +0100)
committerDaira Hopwood <daira@jacaranda.org>
Thu, 1 Oct 2015 00:19:47 +0000 (01:19 +0100)
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
src/allmydata/util/fileutil.py

index 16dda5c0ec3ecc1b193f09204d13fe4f3984a690..a12565f389107d0b59dbea426a02aa5693b453aa 100644 (file)
@@ -619,8 +619,11 @@ else:
         if not os.path.exists(replacement_path):
             raise ConflictError("Replacement file not found: %r" % (replacement_path,))
         try:
-            if os.path.exists(replaced_path):
+            try:
                 os.rename(replaced_path, backup_path)
+            except OSError as e:
+                if e.errno != errno.EEXIST:
+                    raise
             rename_no_overwrite(replacement_path, replaced_path)
         except EnvironmentError:
             reraise(ConflictError)