From: Daira Hopwood Date: Tue, 15 Sep 2015 17:31:20 +0000 (+0100) Subject: replace_file should not fail if replaced_path does not exist. X-Git-Url: https://git.rkrishnan.org/?a=commitdiff_plain;h=60ddd4a19e1ee949f28d6a855033e675bc2459b3;p=tahoe-lafs%2Ftahoe-lafs.git replace_file should not fail if replaced_path does not exist. Signed-off-by: Daira Hopwood --- diff --git a/src/allmydata/util/fileutil.py b/src/allmydata/util/fileutil.py index 16dda5c0..a12565f3 100644 --- a/src/allmydata/util/fileutil.py +++ b/src/allmydata/util/fileutil.py @@ -619,8 +619,11 @@ else: if not os.path.exists(replacement_path): raise ConflictError("Replacement file not found: %r" % (replacement_path,)) try: - if os.path.exists(replaced_path): + 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)