From 5cfddb2438953b0b61ece2a9eff35c523ffc3493 Mon Sep 17 00:00:00 2001 From: David Stainton Date: Wed, 26 Aug 2015 22:02:26 +0200 Subject: [PATCH] Fix replace_file; rename only if replaced_path exists --- src/allmydata/util/fileutil.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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): -- 2.45.2