Skip to content

Commit

Permalink
Include VObject version in item cache hash
Browse files Browse the repository at this point in the history
  • Loading branch information
Unrud committed Jun 23, 2017
1 parent df5565f commit 98caa88
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions radicale/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
from random import getrandbits
from tempfile import NamedTemporaryFile, TemporaryDirectory

import pkg_resources
import vobject

if sys.version_info >= (3, 5):
Expand Down Expand Up @@ -544,6 +545,8 @@ def acquire_lock(cls, mode, user=None):
class Collection(BaseCollection):
"""Collection stored in several files per calendar."""

_item_cache_tag = None

def __init__(self, path, principal=None, folder=None):
# DEPRECATED: Remove useless principal attribute
if folder is None:
Expand All @@ -560,6 +563,15 @@ def __init__(self, path, principal=None, folder=None):
self.is_principal = principal
self._meta_cache = None
self._etag_cache = None
if self._item_cache_tag is None:
try:
vobject_version = pkg_resources.require("vobject")[0].version
self.logger.debug("VObject version: %r", vobject_version)
except Exception as e:
self.logger.warning(
"VObject version not found: %s", e, exc_info=True)
vobject_version = ""
Collection._item_cache_tag = vobject_version.encode() + b"\0"

@classmethod
def _get_collection_root_folder(cls):
Expand Down Expand Up @@ -1015,6 +1027,7 @@ def _get_with_metadata(self, href, verify_href=True):
# The hash of the component in the file system. This is used to check,
# if the entry in the cache is still valid.
input_hash = md5()
input_hash.update(self._item_cache_tag)
input_hash.update(btext)
input_hash = input_hash.hexdigest()
cache_folder = os.path.join(self._filesystem_path, ".Radicale.cache",
Expand Down

0 comments on commit 98caa88

Please sign in to comment.