From: Daira Hopwood Date: Mon, 31 Aug 2015 16:52:55 +0000 (+0100) Subject: replace_file should not fail if replaced_path does not exist. X-Git-Url: https://git.rkrishnan.org/simplejson/components/-?a=commitdiff_plain;h=bfda47fef4e431699d72d8323fdf6bdbbc74445e;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 9a194e99..2debc7f7 100644 --- a/src/allmydata/util/fileutil.py +++ b/src/allmydata/util/fileutil.py @@ -619,7 +619,11 @@ else: if not os.path.exists(replacement_path): raise ConflictError("Replacement file not found: %r" % (replacement_path,)) try: - os.rename(replaced_path, backup_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)