From 3ee543339712e8d6f105430299c6408ab89e8234 Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Fri, 28 Mar 2025 07:35:15 +0100 Subject: [PATCH 1/6] use proper cache location for lock --- radicale/storage/multifilesystem/lock.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/radicale/storage/multifilesystem/lock.py b/radicale/storage/multifilesystem/lock.py index 1e25daee..6e5489ef 100644 --- a/radicale/storage/multifilesystem/lock.py +++ b/radicale/storage/multifilesystem/lock.py @@ -38,10 +38,11 @@ class CollectionPartLock(CollectionBase): if self._storage._lock.locked == "w": yield return - cache_folder = os.path.join(self._filesystem_path, ".Radicale.cache") + cache_folder = self._storage._get_collection_cache_subfolder(self._filesystem_path, ".Radicale.cache", ns) self._storage._makedirs_synced(cache_folder) lock_path = os.path.join(cache_folder, ".Radicale.lock" + (".%s" % ns if ns else "")) + logger.debug("Lock file (CollectionPartLock): %r" % lock_path) lock = pathutils.RwLock(lock_path) with lock.acquire("w"): yield From b744e9658c540413c6825569aa89afb21c84d9fe Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Fri, 28 Mar 2025 07:35:43 +0100 Subject: [PATCH 2/6] use collection-root location for lock instead of base directory --- radicale/storage/multifilesystem/lock.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/radicale/storage/multifilesystem/lock.py b/radicale/storage/multifilesystem/lock.py index 6e5489ef..7298ea1e 100644 --- a/radicale/storage/multifilesystem/lock.py +++ b/radicale/storage/multifilesystem/lock.py @@ -55,7 +55,8 @@ class StoragePartLock(StorageBase): def __init__(self, configuration: config.Configuration) -> None: super().__init__(configuration) - lock_path = os.path.join(self._filesystem_folder, ".Radicale.lock") + lock_path = os.path.join(self._get_collection_root_folder(), ".Radicale.lock") + logger.debug("Lock file (StoragePartLock): %r" % lock_path) self._lock = pathutils.RwLock(lock_path) self._hook = configuration.get("storage", "hook") From c23821ad0cb1b04d439cee491258825309e09166 Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Fri, 28 Mar 2025 07:36:17 +0100 Subject: [PATCH 3/6] 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 From ecaed3188c35360c3871fe72ac8cbcc998a1f3c3 Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Sat, 29 Mar 2025 06:57:10 +0100 Subject: [PATCH 4/6] change location of main lock file back to original --- radicale/storage/multifilesystem/lock.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radicale/storage/multifilesystem/lock.py b/radicale/storage/multifilesystem/lock.py index 7298ea1e..0f7b56d9 100644 --- a/radicale/storage/multifilesystem/lock.py +++ b/radicale/storage/multifilesystem/lock.py @@ -55,7 +55,7 @@ class StoragePartLock(StorageBase): def __init__(self, configuration: config.Configuration) -> None: super().__init__(configuration) - lock_path = os.path.join(self._get_collection_root_folder(), ".Radicale.lock") + lock_path = os.path.join(self._filesystem_folder, ".Radicale.lock") logger.debug("Lock file (StoragePartLock): %r" % lock_path) self._lock = pathutils.RwLock(lock_path) self._hook = configuration.get("storage", "hook") From ffe5fcc6f3cd87c2451556a1fee56de433042415 Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Sat, 29 Mar 2025 07:03:29 +0100 Subject: [PATCH 5/6] lock review changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8bbf8ce0..a002754d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * Fix: auth/htpasswd related to detection and use of bcrypt * Add: option [auth] ldap_ignore_attribute_create_modify_timestamp for support of Authentik LDAP server * Extend: [storage] hook supports now placeholder for "cwd" and "path" (and catches unsupported placeholders) +* Fix: location of lock file for in case of dedicated cache folder is activated ## 3.5.0 From 9ca82a8aa254da56b69485829894225cb50042d7 Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Sat, 29 Mar 2025 07:04:32 +0100 Subject: [PATCH 6/6] base folder log+create --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a002754d..ceaf93bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * Add: option [auth] ldap_ignore_attribute_create_modify_timestamp for support of Authentik LDAP server * Extend: [storage] hook supports now placeholder for "cwd" and "path" (and catches unsupported placeholders) * Fix: location of lock file for in case of dedicated cache folder is activated +* Extend: log and create base folders if not existing during startup ## 3.5.0