From c23821ad0cb1b04d439cee491258825309e09166 Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Fri, 28 Mar 2025 07:36:17 +0100 Subject: [PATCH] conditionally create missing collection* folders on startup --- radicale/storage/multifilesystem/__init__.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/radicale/storage/multifilesystem/__init__.py b/radicale/storage/multifilesystem/__init__.py index c5b8d439..a6191e77 100644 --- a/radicale/storage/multifilesystem/__init__.py +++ b/radicale/storage/multifilesystem/__init__.py @@ -147,8 +147,13 @@ class Storage( def __init__(self, configuration: config.Configuration) -> None: super().__init__(configuration) logger.info("Storage location: %r", self._filesystem_folder) - self._makedirs_synced(self._filesystem_folder) + if not os.path.exists(self._filesystem_folder): + logger.warning("Storage location: %r not existing, create now", self._filesystem_folder) + self._makedirs_synced(self._filesystem_folder) logger.info("Storage location subfolder: %r", self._get_collection_root_folder()) + if not os.path.exists(self._get_collection_root_folder()): + logger.warning("Storage location subfolder: %r not existing, create now", self._get_collection_root_folder()) + self._makedirs_synced(self._get_collection_root_folder()) logger.info("Storage cache subfolder usage for 'item': %s", self._use_cache_subfolder_for_item) logger.info("Storage cache subfolder usage for 'history': %s", self._use_cache_subfolder_for_history) logger.info("Storage cache subfolder usage for 'sync-token': %s", self._use_cache_subfolder_for_synctoken) @@ -170,7 +175,9 @@ class Storage( logger.debug("Storage cache action logging: %s", self._debug_cache_actions) if self._use_cache_subfolder_for_item is True or self._use_cache_subfolder_for_history is True or self._use_cache_subfolder_for_synctoken is True: logger.info("Storage cache subfolder: %r", self._get_collection_cache_folder()) - self._makedirs_synced(self._get_collection_cache_folder()) + if not os.path.exists(self._get_collection_cache_folder()): + logger.warning("Storage cache subfolder: %r not existing, create now", self._get_collection_cache_folder()) + self._makedirs_synced(self._get_collection_cache_folder()) if sys.platform != "win32": if not self._folder_umask: # retrieve current umask by setting a dummy umask