]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
More precise and correct error reporting in replace_file.
authorDaira Hopwood <daira@jacaranda.org>
Mon, 31 Aug 2015 17:05:33 +0000 (18:05 +0100)
committerDaira Hopwood <daira@jacaranda.org>
Tue, 15 Sep 2015 17:42:59 +0000 (18:42 +0100)
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
src/allmydata/util/fileutil.py

index a12565f389107d0b59dbea426a02aa5693b453aa..ceb6c6eb95a8cc19ac2863e5e61ca153392946c9 100644 (file)
@@ -4,7 +4,7 @@ Futz with files like a pro.
 
 import sys, exceptions, os, stat, tempfile, time, binascii
 from collections import namedtuple
-from errno import EEXIST, ENOENT
+from errno import ENOENT
 
 from twisted.python import log
 
@@ -618,12 +618,14 @@ else:
 
         if not os.path.exists(replacement_path):
             raise ConflictError("Replacement file not found: %r" % (replacement_path,))
+
+        try:
+            os.rename(replaced_path, backup_path)
+        except OSError as e:
+            print e, e.errno
+            if e.errno != ENOENT:
+                raise
         try:
-            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)