From b8126f8d24ff3c40188ba0f578761019e55596c1 Mon Sep 17 00:00:00 2001 From: Unrud Date: Wed, 10 Aug 2016 19:26:07 +0200 Subject: [PATCH] Use os.replace instead of os.rename On Windows os.replace sets the MOVEFILE_REPLACE_EXISTING flag for MoveFileEx. On POSIX it's the same as os.rename. --- radicale/storage.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/radicale/storage.py b/radicale/storage.py index c04f2ef..594dc06 100644 --- a/radicale/storage.py +++ b/radicale/storage.py @@ -404,7 +404,7 @@ class Collection(BaseCollection): else: os.fsync(tmp.fileno()) tmp.close() - os.rename(tmp.name, path) + os.replace(tmp.name, path) except: tmp.close() os.remove(tmp.name) @@ -574,7 +574,7 @@ class Collection(BaseCollection): @classmethod def move(cls, item, to_collection, to_href): - os.rename( + os.replace( path_to_filesystem(item.collection._filesystem_path, item.href), path_to_filesystem(to_collection._filesystem_path, to_href)) cls._sync_directory(to_collection._filesystem_path)