Add way to invalidate discovery cache

This commit is contained in:
Markus Unterwaditzer 2015-07-06 16:21:37 +02:00
parent fe1d512b38
commit acf3ac0dcd
2 changed files with 8 additions and 1 deletions

View file

@ -8,3 +8,7 @@ __version__ = pkg_resources.get_distribution('vdirsyncer').version
PROJECT_HOME = 'https://github.com/untitaker/vdirsyncer'
DOCS_HOME = 'https://vdirsyncer.readthedocs.org/en/latest'
# Increase whenever upgrade potentially breaks discovery cache and collections
# should be re-discovered
discovery_cache_version = 1

View file

@ -145,10 +145,13 @@ def get_status_name(pair, collection):
def _get_collections_cache_key(pair_options, config_a, config_b):
from vdirsyncer import discovery_cache_version
m = hashlib.sha256()
j = json.dumps([
discovery_cache_version,
pair_options.get('collections', None),
config_a, config_b
config_a,
config_b
], sort_keys=True)
m.update(j.encode('utf-8'))
return m.hexdigest()