From 46c636e642682ea43c03bec7806074046320e900 Mon Sep 17 00:00:00 2001 From: Unrud Date: Thu, 27 Jul 2017 19:08:02 +0200 Subject: [PATCH] Move item cache entry when item is moved --- radicale/storage.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/radicale/storage.py b/radicale/storage.py index a2a6a1c..3c1e51e 100644 --- a/radicale/storage.py +++ b/radicale/storage.py @@ -963,6 +963,21 @@ class Collection(BaseCollection): cls._sync_directory(to_collection._filesystem_path) if item.collection._filesystem_path != to_collection._filesystem_path: cls._sync_directory(item.collection._filesystem_path) + # Move the item cache entry + cache_folder = os.path.join(item.collection._filesystem_path, + ".Radicale.cache", "item") + to_cache_folder = os.path.join(to_collection._filesystem_path, + ".Radicale.cache", "item") + cls._makedirs_synced(to_cache_folder) + try: + os.replace(os.path.join(cache_folder, item.href), + os.path.join(to_cache_folder, to_href)) + except FileNotFoundError: + pass + else: + cls._makedirs_synced(to_cache_folder) + if cache_folder != to_cache_folder: + cls._makedirs_synced(cache_folder) # Track the change to_collection._update_history_etag(to_href, item) item.collection._update_history_etag(item.href, None)