Include versions in item cache hash
This commit is contained in:
parent
f708a7b2b6
commit
5d969ff65c
@ -40,10 +40,10 @@ from contextlib import contextmanager
|
||||
from hashlib import md5
|
||||
from importlib import import_module
|
||||
from itertools import chain, groupby
|
||||
from math import log
|
||||
from random import getrandbits
|
||||
from tempfile import NamedTemporaryFile, TemporaryDirectory
|
||||
|
||||
import pkg_resources
|
||||
import vobject
|
||||
|
||||
from radicale import xmlutils
|
||||
@ -90,6 +90,10 @@ elif os.name == "posix":
|
||||
|
||||
INTERNAL_TYPES = ("multifilesystem",)
|
||||
|
||||
DEPS = ("radicale", "vobject", "python-dateutil",)
|
||||
ITEM_CACHE_TAG = (";".join(pkg_resources.get_distribution(pkg).version
|
||||
for pkg in DEPS) + ";").encode()
|
||||
|
||||
|
||||
def load(configuration):
|
||||
"""Load the storage manager chosen in configuration."""
|
||||
@ -331,11 +335,6 @@ def path_to_filesystem(root, *paths):
|
||||
return safe_path
|
||||
|
||||
|
||||
def left_encode_int(v):
|
||||
length = int(log(v, 256)) + 1 if v != 0 else 1
|
||||
return bytes((length,)) + v.to_bytes(length, 'little')
|
||||
|
||||
|
||||
class UnsafePathError(ValueError):
|
||||
def __init__(self, path):
|
||||
message = "Can't translate name safely to filesystem: %r" % path
|
||||
@ -723,9 +722,6 @@ class BaseCollection:
|
||||
return True
|
||||
|
||||
|
||||
ITEM_CACHE_VERSION = 1
|
||||
|
||||
|
||||
class Collection(BaseCollection):
|
||||
"""Collection stored in several files per calendar."""
|
||||
|
||||
@ -1277,7 +1273,7 @@ class Collection(BaseCollection):
|
||||
|
||||
def _item_cache_hash(self, raw_text):
|
||||
_hash = md5()
|
||||
_hash.update(left_encode_int(ITEM_CACHE_VERSION))
|
||||
_hash.update(ITEM_CACHE_TAG)
|
||||
_hash.update(raw_text)
|
||||
return _hash.hexdigest()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user