mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-10-08 18:31:07 +03:00
update: invalidate cache if allow_disabled_algorithms changes
Since the cache contains implicitly the result of the jarsigner verify, if the allow_disabled_algorithms config changes, then the apkcache is invalid.
This commit is contained in:
parent
e75cabfe77
commit
56ee5de2bd
1 changed files with 18 additions and 4 deletions
|
@ -423,20 +423,35 @@ def get_cache_file():
|
||||||
|
|
||||||
|
|
||||||
def get_cache():
|
def get_cache():
|
||||||
"""
|
"""Get the cached dict of the APK index
|
||||||
|
|
||||||
Gather information about all the apk files in the repo directory,
|
Gather information about all the apk files in the repo directory,
|
||||||
using cached data if possible.
|
using cached data if possible. Some of the index operations take a
|
||||||
|
long time, like calculating the SHA-256 and verifying the APK
|
||||||
|
signature.
|
||||||
|
|
||||||
|
The cache is invalidated if the metadata version is different, or
|
||||||
|
the 'allow_disabled_algorithms' config/option is different. In
|
||||||
|
those cases, there is no easy way to know what has changed from
|
||||||
|
the cache, so just rerun the whole thing.
|
||||||
|
|
||||||
:return: apkcache
|
:return: apkcache
|
||||||
|
|
||||||
"""
|
"""
|
||||||
apkcachefile = get_cache_file()
|
apkcachefile = get_cache_file()
|
||||||
|
ada = options.allow_disabled_algorithms or config['allow_disabled_algorithms']
|
||||||
if not options.clean and os.path.exists(apkcachefile):
|
if not options.clean and os.path.exists(apkcachefile):
|
||||||
with open(apkcachefile, 'rb') as cf:
|
with open(apkcachefile, 'rb') as cf:
|
||||||
apkcache = pickle.load(cf, encoding='utf-8')
|
apkcache = pickle.load(cf, encoding='utf-8')
|
||||||
if apkcache.get("METADATA_VERSION") != METADATA_VERSION:
|
if apkcache.get("METADATA_VERSION") != METADATA_VERSION \
|
||||||
|
or apkcache.get('allow_disabled_algorithms') != ada:
|
||||||
apkcache = {}
|
apkcache = {}
|
||||||
else:
|
else:
|
||||||
apkcache = {}
|
apkcache = {}
|
||||||
|
|
||||||
|
apkcache["METADATA_VERSION"] = METADATA_VERSION
|
||||||
|
apkcache['allow_disabled_algorithms'] = ada
|
||||||
|
|
||||||
return apkcache
|
return apkcache
|
||||||
|
|
||||||
|
|
||||||
|
@ -445,7 +460,6 @@ def write_cache(apkcache):
|
||||||
cache_path = os.path.dirname(apkcachefile)
|
cache_path = os.path.dirname(apkcachefile)
|
||||||
if not os.path.exists(cache_path):
|
if not os.path.exists(cache_path):
|
||||||
os.makedirs(cache_path)
|
os.makedirs(cache_path)
|
||||||
apkcache["METADATA_VERSION"] = METADATA_VERSION
|
|
||||||
with open(apkcachefile, 'wb') as cf:
|
with open(apkcachefile, 'wb') as cf:
|
||||||
pickle.dump(apkcache, cf)
|
pickle.dump(apkcache, cf)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue