From: David Stainton Date: Wed, 26 Aug 2015 20:02:26 +0000 (+0200) Subject: Fix replace_file; rename only if replaced_path exists X-Git-Url: https://git.rkrishnan.org/reedownlee?a=commitdiff_plain;h=6a342f3a61a4d1c9c1db19cae8c3de7e6e8cafbb;p=tahoe-lafs%2Ftahoe-lafs.git Fix replace_file; rename only if replaced_path exists --- 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):