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/?a=commitdiff_plain;h=5cfddb2438953b0b61ece2a9eff35c523ffc3493;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):