1
0
Fork 0
mirror of https://github.com/Kozea/Radicale.git synced 2025-08-07 18:30:54 +00:00

catch permissions errors and display owner+user information

This commit is contained in:
Peter Bieringer 2025-06-29 08:35:26 +02:00
parent 9c50f154fd
commit e36d5f2c01
2 changed files with 12 additions and 3 deletions

View file

@ -29,7 +29,7 @@ import sys
import time import time
from typing import ClassVar, Iterator, Optional, Type from typing import ClassVar, Iterator, Optional, Type
from radicale import config from radicale import config, pathutils, utils
from radicale.log import logger from radicale.log import logger
from radicale.storage.multifilesystem.base import CollectionBase, StorageBase from radicale.storage.multifilesystem.base import CollectionBase, StorageBase
from radicale.storage.multifilesystem.cache import CollectionPartCache 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)) logger.info("Storage item mtime resolution test result: %d %s" % (precision_unit, unit))
if self._use_mtime_and_size_for_item_cache is False: 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") 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: except Exception:
logger.warning("Storage item mtime resolution test result not successful") logger.warning("Storage item mtime resolution test result not successful")
logger.debug("Storage cache action logging: %s", self._debug_cache_actions) logger.debug("Storage cache action logging: %s", self._debug_cache_actions)

View file

@ -22,7 +22,7 @@ import sys
from tempfile import TemporaryDirectory from tempfile import TemporaryDirectory
from typing import IO, AnyStr, ClassVar, Iterator, Optional, Type 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 from radicale.storage import multifilesystem # noqa:F401
@ -161,7 +161,13 @@ class StorageBase(storage.BaseStorage):
# Create parent dirs recursively # Create parent dirs recursively
self._makedirs_synced(parent_filesystem_path) self._makedirs_synced(parent_filesystem_path)
# Possible race! # 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) self._sync_directory(parent_filesystem_path)
if sys.platform != "win32" and self._folder_umask: if sys.platform != "win32" and self._folder_umask:
os.umask(oldmask) os.umask(oldmask)