From b56c55bab4a5d7eca240b227143e1bd6554d8baa Mon Sep 17 00:00:00 2001 From: Daira Hopwood Date: Tue, 2 Jun 2015 02:09:25 +0100 Subject: [PATCH] fileutil: make the error behaviour of replace_file on Unix more similar to Windows. Signed-off-by: Daira Hopwood --- src/allmydata/util/fileutil.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/allmydata/util/fileutil.py b/src/allmydata/util/fileutil.py index 7902e8b8..07c417f9 100644 --- a/src/allmydata/util/fileutil.py +++ b/src/allmydata/util/fileutil.py @@ -625,6 +625,8 @@ else: precondition_abspath(replacement_path) precondition_abspath(backup_path) + if not os.path.exists(replacement_path): + raise ConflictError("Replacement file not found: %r" % (replacement_path,)) try: os.rename(replaced_path, backup_path) rename_no_overwrite(replacement_path, replaced_path) -- 2.45.2