|
2 | 2 | # Copyright © 2014 Jean-Marc Martins |
3 | 3 | # Copyright © 2012-2017 Guillaume Ayoub |
4 | 4 | # Copyright © 2017-2021 Unrud <unrud@outlook.com> |
5 | | -# Copyright © 2024-2024 Peter Bieringer <pb@bieringer.de> |
| 5 | +# Copyright © 2024-2025 Peter Bieringer <pb@bieringer.de> |
6 | 6 | # |
7 | 7 | # This library is free software: you can redistribute it and/or modify |
8 | 8 | # it under the terms of the GNU General Public License as published by |
@@ -95,15 +95,21 @@ class Storage( |
95 | 95 | def _analyse_mtime(self): |
96 | 96 | # calculate and display mtime resolution |
97 | 97 | path = os.path.join(self._filesystem_folder, ".Radicale.mtime_test") |
| 98 | + logger.debug("Storage item mtime resolution test with file: %r", path) |
98 | 99 | try: |
99 | 100 | with open(path, "w") as f: |
100 | 101 | f.write("mtime_test") |
101 | 102 | f.close |
102 | 103 | except Exception as e: |
103 | | - logger.error("Storage item mtime resolution test not possible, cannot write file: %r (%s)", path, e) |
| 104 | + logger.warning("Storage item mtime resolution test not possible, cannot write file: %r (%s)", path, e) |
104 | 105 | raise |
105 | 106 | # set mtime_ns for tests |
106 | | - os.utime(path, times=None, ns=(MTIME_NS_TEST, MTIME_NS_TEST)) |
| 107 | + try: |
| 108 | + os.utime(path, times=None, ns=(MTIME_NS_TEST, MTIME_NS_TEST)) |
| 109 | + except Exception as e: |
| 110 | + logger.warning("Storage item mtime resolution test not possible, cannot set utime on file: %r (%s)", path, e) |
| 111 | + os.remove(path) |
| 112 | + raise |
107 | 113 | logger.debug("Storage item mtime resoultion test set: %d" % MTIME_NS_TEST) |
108 | 114 | mtime_ns = os.stat(path).st_mtime_ns |
109 | 115 | logger.debug("Storage item mtime resoultion test get: %d" % mtime_ns) |
@@ -147,17 +153,20 @@ def __init__(self, configuration: config.Configuration) -> None: |
147 | 153 | logger.info("Storage cache subfolder usage for 'history': %s", self._use_cache_subfolder_for_history) |
148 | 154 | logger.info("Storage cache subfolder usage for 'sync-token': %s", self._use_cache_subfolder_for_synctoken) |
149 | 155 | logger.info("Storage cache use mtime and size for 'item': %s", self._use_mtime_and_size_for_item_cache) |
150 | | - (precision, precision_unit, unit) = self._analyse_mtime() |
151 | | - if precision >= 100000000: |
152 | | - # >= 100 ms |
153 | | - logger.warning("Storage item mtime resolution test result: %d %s (VERY RISKY ON PRODUCTION SYSTEMS)" % (precision_unit, unit)) |
154 | | - elif precision >= 10000000: |
155 | | - # >= 10 ms |
156 | | - logger.warning("Storage item mtime resolution test result: %d %s (RISKY ON PRODUCTION SYSTEMS)" % (precision_unit, unit)) |
157 | | - else: |
158 | | - logger.info("Storage item mtime resolution test result: %d %s" % (precision_unit, unit)) |
159 | | - if self._use_mtime_and_size_for_item_cache is False: |
160 | | - logger.info("Storage cache using mtime and size for 'item' may be an option in case of performance issues") |
| 156 | + try: |
| 157 | + (precision, precision_unit, unit) = self._analyse_mtime() |
| 158 | + if precision >= 100000000: |
| 159 | + # >= 100 ms |
| 160 | + logger.warning("Storage item mtime resolution test result: %d %s (VERY RISKY ON PRODUCTION SYSTEMS)" % (precision_unit, unit)) |
| 161 | + elif precision >= 10000000: |
| 162 | + # >= 10 ms |
| 163 | + logger.warning("Storage item mtime resolution test result: %d %s (RISKY ON PRODUCTION SYSTEMS)" % (precision_unit, unit)) |
| 164 | + else: |
| 165 | + logger.info("Storage item mtime resolution test result: %d %s" % (precision_unit, unit)) |
| 166 | + if self._use_mtime_and_size_for_item_cache is False: |
| 167 | + logger.info("Storage cache using mtime and size for 'item' may be an option in case of performance issues") |
| 168 | + except Exception: |
| 169 | + logger.warning("Storage item mtime resolution test result not successful") |
161 | 170 | logger.debug("Storage cache action logging: %s", self._debug_cache_actions) |
162 | 171 | 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: |
163 | 172 | logger.info("Storage cache subfolder: %r", self._get_collection_cache_folder()) |
|
0 commit comments