From: Hans-Christoph Steiner Date: Wed, 15 Jun 2016 14:34:10 +0000 (+0200) Subject: invalidate apkcache if the metadata version is different X-Git-Tag: 0.7.0~49^2 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=8e57f2737d97b9ce9bf23e118162b6e481617c51;p=fdroidserver.git invalidate apkcache if the metadata version is different When the metadata changes, different things will be stored about each APK. So invalidate the cached info parsed from APKs if the cache's metadata version does not match the metadata version of the currently running tools. --- diff --git a/fdroidserver/update.py b/fdroidserver/update.py index cd75449d..7cd18f41 100644 --- a/fdroidserver/update.py +++ b/fdroidserver/update.py @@ -44,6 +44,8 @@ from . import metadata from .common import FDroidPopen, FDroidPopenBytes, SdkToolsPopen from .metadata import MetaDataException +METADATA_VERSION = 16 + screen_densities = ['640', '480', '320', '240', '160', '120'] all_screen_densities = ['0'] + screen_densities @@ -811,7 +813,7 @@ def make_index(apps, sortedids, apks, repodir, archive, categories): for mirror in config.get('mirrors', []): addElement('mirror', urllib.parse.urljoin(mirror, urlbasepath), doc, repoel) - repoel.setAttribute("version", "16") + repoel.setAttribute("version", str(METADATA_VERSION)) repoel.setAttribute("timestamp", str(int(time.time()))) nosigningkey = False @@ -1224,6 +1226,8 @@ def main(): if not options.clean and os.path.exists(apkcachefile): with open(apkcachefile, 'rb') as cf: apkcache = pickle.load(cf, encoding='utf-8') + if apkcache.get("METADATA_VERSION") != METADATA_VERSION: + apkcache = {} else: apkcache = {} @@ -1364,6 +1368,7 @@ def main(): f.write(data) if cachechanged: + apkcache["METADATA_VERSION"] = METADATA_VERSION with open(apkcachefile, 'wb') as cf: pickle.dump(apkcache, cf)