1
0
Fork 0
mirror of https://github.com/Kozea/Radicale.git synced 2025-06-26 16:45:52 +00:00

Merge pull request #1706 from pbiering/relax-mtime-resolution-check

Relax mtime resolution check
This commit is contained in:
Peter Bieringer 2025-02-20 21:22:00 +01:00 committed by GitHub
commit 63e414850e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 14 deletions

View file

@ -5,6 +5,7 @@
* Add: option [auth] type oauth2 by code migration from https://gitlab.mim-libre.fr/alphabet/radicale_oauth/-/blob/dev/oauth2/ * Add: option [auth] type oauth2 by code migration from https://gitlab.mim-libre.fr/alphabet/radicale_oauth/-/blob/dev/oauth2/
* Fix: catch OS errors on PUT MKCOL MKCALENDAR MOVE PROPPATCH (insufficient storage, access denied, internal server error) * Fix: catch OS errors on PUT MKCOL MKCALENDAR MOVE PROPPATCH (insufficient storage, access denied, internal server error)
* Test: skip bcrypt related tests if module is missing * Test: skip bcrypt related tests if module is missing
* Improve: relax mtime check on storage filesystem
## 3.4.1 ## 3.4.1
* Add: option [auth] dovecot_connection_type / dovecot_host / dovecot_port * Add: option [auth] dovecot_connection_type / dovecot_host / dovecot_port

View file

@ -2,7 +2,7 @@
# Copyright © 2014 Jean-Marc Martins # Copyright © 2014 Jean-Marc Martins
# Copyright © 2012-2017 Guillaume Ayoub # Copyright © 2012-2017 Guillaume Ayoub
# Copyright © 2017-2021 Unrud <unrud@outlook.com> # Copyright © 2017-2021 Unrud <unrud@outlook.com>
# Copyright © 2024-2024 Peter Bieringer <pb@bieringer.de> # Copyright © 2024-2025 Peter Bieringer <pb@bieringer.de>
# #
# This library is free software: you can redistribute it and/or modify # This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -95,15 +95,21 @@ class Storage(
def _analyse_mtime(self): def _analyse_mtime(self):
# calculate and display mtime resolution # calculate and display mtime resolution
path = os.path.join(self._filesystem_folder, ".Radicale.mtime_test") path = os.path.join(self._filesystem_folder, ".Radicale.mtime_test")
logger.debug("Storage item mtime resolution test with file: %r", path)
try: try:
with open(path, "w") as f: with open(path, "w") as f:
f.write("mtime_test") f.write("mtime_test")
f.close f.close
except Exception as e: except Exception as e:
logger.error("Storage item mtime resolution test not possible, cannot write file: %r (%s)", path, e) logger.warning("Storage item mtime resolution test not possible, cannot write file: %r (%s)", path, e)
raise raise
# set mtime_ns for tests # set mtime_ns for tests
try:
os.utime(path, times=None, ns=(MTIME_NS_TEST, MTIME_NS_TEST)) os.utime(path, times=None, ns=(MTIME_NS_TEST, MTIME_NS_TEST))
except Exception as e:
logger.warning("Storage item mtime resolution test not possible, cannot set utime on file: %r (%s)", path, e)
os.remove(path)
raise
logger.debug("Storage item mtime resoultion test set: %d" % MTIME_NS_TEST) logger.debug("Storage item mtime resoultion test set: %d" % MTIME_NS_TEST)
mtime_ns = os.stat(path).st_mtime_ns mtime_ns = os.stat(path).st_mtime_ns
logger.debug("Storage item mtime resoultion test get: %d" % mtime_ns) logger.debug("Storage item mtime resoultion test get: %d" % mtime_ns)
@ -147,6 +153,7 @@ class Storage(
logger.info("Storage cache subfolder usage for 'history': %s", self._use_cache_subfolder_for_history) 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) logger.info("Storage cache subfolder usage for 'sync-token': %s", self._use_cache_subfolder_for_synctoken)
logger.info("Storage cache use mtime and size for 'item': %s", self._use_mtime_and_size_for_item_cache) logger.info("Storage cache use mtime and size for 'item': %s", self._use_mtime_and_size_for_item_cache)
try:
(precision, precision_unit, unit) = self._analyse_mtime() (precision, precision_unit, unit) = self._analyse_mtime()
if precision >= 100000000: if precision >= 100000000:
# >= 100 ms # >= 100 ms
@ -158,6 +165,8 @@ 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 Exception:
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)
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: 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()) logger.info("Storage cache subfolder: %r", self._get_collection_cache_folder())