From: Daira Hopwood Date: Mon, 31 Aug 2015 17:05:33 +0000 (+0100) Subject: More precise and correct error reporting in replace_file. X-Git-Url: https://git.rkrishnan.org/pf/content/en/footer/status?a=commitdiff_plain;h=5b3b8463ae75cda6248eb604e01f1bf0bb13c7c0;p=tahoe-lafs%2Ftahoe-lafs.git More precise and correct error reporting in replace_file. Signed-off-by: Daira Hopwood --- diff --git a/src/allmydata/util/fileutil.py b/src/allmydata/util/fileutil.py index 2debc7f7..cbb8d709 100644 --- a/src/allmydata/util/fileutil.py +++ b/src/allmydata/util/fileutil.py @@ -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)