From e36d5f2c014c7cb43826d940f9395ded733ff6c4 Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Sun, 29 Jun 2025 08:35:26 +0200 Subject: [PATCH] catch permissions errors and display owner+user information --- radicale/storage/multifilesystem/__init__.py | 5 ++++- radicale/storage/multifilesystem/base.py | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/radicale/storage/multifilesystem/__init__.py b/radicale/storage/multifilesystem/__init__.py index 2aa1309a..5ef0514c 100644 --- a/radicale/storage/multifilesystem/__init__.py +++ b/radicale/storage/multifilesystem/__init__.py @@ -29,7 +29,7 @@ import sys import time from typing import ClassVar, Iterator, Optional, Type -from radicale import config +from radicale import config, pathutils, utils from radicale.log import logger from radicale.storage.multifilesystem.base import CollectionBase, StorageBase from radicale.storage.multifilesystem.cache import CollectionPartCache @@ -187,6 +187,9 @@ class Storage( logger.info("Storage item mtime resolution test result: %d %s" % (precision_unit, unit)) if self._use_mtime_and_size_for_item_cache is False: logger.info("Storage cache using mtime and size for 'item' may be an option in case of performance issues") + except PermissionError as e: + logger.error("Directory permissions: %s / Effective user: %s", pathutils.path_permissions_as_string(self._get_collection_root_folder()), utils.user_groups_as_string()) + raise e except Exception: logger.warning("Storage item mtime resolution test result not successful") logger.debug("Storage cache action logging: %s", self._debug_cache_actions) diff --git a/radicale/storage/multifilesystem/base.py b/radicale/storage/multifilesystem/base.py index 394e89bf..f0fe3dd5 100644 --- a/radicale/storage/multifilesystem/base.py +++ b/radicale/storage/multifilesystem/base.py @@ -22,7 +22,7 @@ import sys from tempfile import TemporaryDirectory from typing import IO, AnyStr, ClassVar, Iterator, Optional, Type -from radicale import config, pathutils, storage, types +from radicale import config, logger, pathutils, storage, types, utils from radicale.storage import multifilesystem # noqa:F401 @@ -161,7 +161,13 @@ class StorageBase(storage.BaseStorage): # Create parent dirs recursively self._makedirs_synced(parent_filesystem_path) # Possible race! - os.makedirs(filesystem_path, exist_ok=True) + try: + os.makedirs(filesystem_path, exist_ok=True) + except PermissionError as e: + logger.error("Directory permissions: %s / Effective user: %s", pathutils.path_permissions_as_string(parent_filesystem_path), utils.user_groups_as_string()) + raise e + except Exception: + raise self._sync_directory(parent_filesystem_path) if sys.platform != "win32" and self._folder_umask: os.umask(oldmask)