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/components/com_hotproperty/flags/status?a=commitdiff_plain;h=24ec381dda1bee53a64e8178aacbc4c0b7757a92;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):