replace_file should not fail if replaced_path does not exist.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
Daira Hopwood 2015-08-31 17:52:55 +01:00
parent 472e267075
commit bfda47fef4

View File

@ -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)