From 3983b5c887d4f1649773927934e291971d469c19 Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Sat, 14 Dec 2024 08:21:54 +0100 Subject: [PATCH 1/4] Improve: avoid automatically invalid cache on upgrade in case no change on cache structure --- CHANGELOG.md | 1 + radicale/storage/__init__.py | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9263f50d..8d8f465d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ * Add: option [storage] use_cache_subfolder_for_synctoken for storing 'sync-token' cache outside collection-root * Add: option [storage] folder_umask for configuration of umask (overwrite system-default) * Fix: also remove 'item' from cache on delete +* Improve: avoid automatically invalid cache on upgrade in case no change on cache structure ## 3.3.1 diff --git a/radicale/storage/__init__.py b/radicale/storage/__init__.py index 58f2a499..44f2e758 100644 --- a/radicale/storage/__init__.py +++ b/radicale/storage/__init__.py @@ -32,20 +32,22 @@ import vobject from radicale import config +from radicale.log import logger from radicale import item as radicale_item from radicale import types, utils from radicale.item import filter as radicale_filter INTERNAL_TYPES: Sequence[str] = ("multifilesystem", "multifilesystem_nolock",) -CACHE_DEPS: Sequence[str] = ("radicale", "vobject") -CACHE_VERSION: bytes = "".join( - "%s=%s;" % (pkg, utils.package_version(pkg)) - for pkg in CACHE_DEPS).encode() +# NOTE: change only if cache structure is modified to avoid cache invalidation on update +CACHE_VERSION_RADICALE = "3.3.1" + +CACHE_VERSION: bytes = ("%s=%s;%s=%s;" % ("radicale", CACHE_VERSION_RADICALE, "vobject", utils.package_version("vobject"))).encode() def load(configuration: "config.Configuration") -> "BaseStorage": """Load the storage module chosen in configuration.""" + logger.debug("storage cache version: %r", str(CACHE_VERSION)) return utils.load_plugin(INTERNAL_TYPES, "storage", "Storage", BaseStorage, configuration) From 119cefce347f4ee2ba2ed8e7ede9daee362e97eb Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Sat, 14 Dec 2024 08:22:22 +0100 Subject: [PATCH 2/4] Improve: log important module versions on startup --- CHANGELOG.md | 1 + radicale/server.py | 2 +- radicale/utils.py | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d8f465d..cce047e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ * Add: option [storage] folder_umask for configuration of umask (overwrite system-default) * Fix: also remove 'item' from cache on delete * Improve: avoid automatically invalid cache on upgrade in case no change on cache structure +* Improve: log important module versions on startup ## 3.3.1 diff --git a/radicale/server.py b/radicale/server.py index 80e58fd3..23396330 100644 --- a/radicale/server.py +++ b/radicale/server.py @@ -301,7 +301,7 @@ def serve(configuration: config.Configuration, """ - logger.info("Starting Radicale") + logger.info("Starting Radicale (%s)", utils.packages_version()) # Copy configuration before modifying configuration = configuration.copy() configuration.update({"server": {"_internal_server": "True"}}, "server", diff --git a/radicale/utils.py b/radicale/utils.py index 50a8d822..1223d330 100644 --- a/radicale/utils.py +++ b/radicale/utils.py @@ -26,6 +26,7 @@ _T_co = TypeVar("_T_co", covariant=True) +RADICALE_MODULES: Sequence[str] = ("radicale", "vobject", "passlib", "defusedxml") def load_plugin(internal_types: Sequence[str], module_name: str, class_name: str, base_class: Type[_T_co], @@ -50,6 +51,11 @@ def load_plugin(internal_types: Sequence[str], module_name: str, def package_version(name): return metadata.version(name) +def packages_version(): + versions = [] + for pkg in RADICALE_MODULES: + versions.append("%s=%s" % (pkg, package_version(pkg))) + return " ".join(versions) def ssl_context_options_by_protocol(protocol: str, ssl_context_options): logger.debug("SSL protocol string: '%s' and current SSL context options: '0x%x'", protocol, ssl_context_options) From 1e318c81cf7c103cb24b6f20121793a3e6b566bc Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Sat, 14 Dec 2024 08:22:51 +0100 Subject: [PATCH 3/4] fix copyright --- radicale/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radicale/server.py b/radicale/server.py index 23396330..77080117 100644 --- a/radicale/server.py +++ b/radicale/server.py @@ -2,7 +2,7 @@ # Copyright © 2008 Nicolas Kandel # Copyright © 2008 Pascal Halter # Copyright © 2008-2017 Guillaume Ayoub -# Copyright © 2017-2019 Unrud +# Copyright © 2017-2023 Unrud # Copyright © 2024-2024 Peter Bieringer # # This library is free software: you can redistribute it and/or modify From 9787f87cc79265359b8fcb742334c34e7892fc31 Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Sat, 14 Dec 2024 08:36:03 +0100 Subject: [PATCH 4/4] make tox happy --- radicale/storage/__init__.py | 3 ++- radicale/utils.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/radicale/storage/__init__.py b/radicale/storage/__init__.py index 44f2e758..da89bcf3 100644 --- a/radicale/storage/__init__.py +++ b/radicale/storage/__init__.py @@ -2,6 +2,7 @@ # Copyright © 2014 Jean-Marc Martins # Copyright © 2012-2017 Guillaume Ayoub # Copyright © 2017-2022 Unrud +# Copyright © 2024-2024 Peter Bieringer # # 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 @@ -32,10 +33,10 @@ import vobject from radicale import config -from radicale.log import logger from radicale import item as radicale_item from radicale import types, utils from radicale.item import filter as radicale_filter +from radicale.log import logger INTERNAL_TYPES: Sequence[str] = ("multifilesystem", "multifilesystem_nolock",) diff --git a/radicale/utils.py b/radicale/utils.py index 1223d330..097be3fb 100644 --- a/radicale/utils.py +++ b/radicale/utils.py @@ -28,6 +28,7 @@ RADICALE_MODULES: Sequence[str] = ("radicale", "vobject", "passlib", "defusedxml") + def load_plugin(internal_types: Sequence[str], module_name: str, class_name: str, base_class: Type[_T_co], configuration: "config.Configuration") -> _T_co: @@ -51,12 +52,14 @@ def load_plugin(internal_types: Sequence[str], module_name: str, def package_version(name): return metadata.version(name) + def packages_version(): versions = [] for pkg in RADICALE_MODULES: versions.append("%s=%s" % (pkg, package_version(pkg))) return " ".join(versions) + def ssl_context_options_by_protocol(protocol: str, ssl_context_options): logger.debug("SSL protocol string: '%s' and current SSL context options: '0x%x'", protocol, ssl_context_options) # disable any protocol by default