fileutil: make the error behaviour of replace_file on Unix more similar to Windows.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
Daira Hopwood 2015-06-02 02:09:25 +01:00
parent 3cffe2599e
commit a2cb04fe7d
1 changed files with 2 additions and 0 deletions

View File

@ -615,6 +615,8 @@ else:
precondition_abspath(replacement_path) precondition_abspath(replacement_path)
precondition_abspath(backup_path) precondition_abspath(backup_path)
if not os.path.exists(replacement_path):
raise ConflictError("Replacement file not found: %r" % (replacement_path,))
try: try:
os.rename(replaced_path, backup_path) os.rename(replaced_path, backup_path)
rename_no_overwrite(replacement_path, replaced_path) rename_no_overwrite(replacement_path, replaced_path)