mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-05 15:00:30 +03:00
update: test if options is instantated before using attributes
This makes it possible to use process_apks(), get_cache(), and anything calling disabled_algorithms_allowed() as an API without having to set options up beforehand.
This commit is contained in:
parent
790b5a2888
commit
3c64996089
1 changed files with 5 additions and 3 deletions
|
|
@ -123,7 +123,9 @@ def get_all_icon_dirs(repodir):
|
||||||
|
|
||||||
|
|
||||||
def disabled_algorithms_allowed():
|
def disabled_algorithms_allowed():
|
||||||
return options.allow_disabled_algorithms or config['allow_disabled_algorithms']
|
return ((options is not None and options.allow_disabled_algorithms)
|
||||||
|
or (config is not None and config['allow_disabled_algorithms'])
|
||||||
|
or common.default_config['allow_disabled_algorithms'])
|
||||||
|
|
||||||
|
|
||||||
def status_update_json(apps, apks):
|
def status_update_json(apps, apks):
|
||||||
|
|
@ -521,7 +523,7 @@ def get_cache():
|
||||||
"""
|
"""
|
||||||
apkcachefile = get_cache_file()
|
apkcachefile = get_cache_file()
|
||||||
ada = disabled_algorithms_allowed()
|
ada = disabled_algorithms_allowed()
|
||||||
if not options.clean and os.path.exists(apkcachefile):
|
if options is not None and not options.clean and os.path.exists(apkcachefile):
|
||||||
with open(apkcachefile) as fp:
|
with open(apkcachefile) as fp:
|
||||||
apkcache = json.load(fp, object_pairs_hook=collections.OrderedDict)
|
apkcache = json.load(fp, object_pairs_hook=collections.OrderedDict)
|
||||||
if apkcache.get("METADATA_VERSION") != METADATA_VERSION \
|
if apkcache.get("METADATA_VERSION") != METADATA_VERSION \
|
||||||
|
|
@ -1778,7 +1780,7 @@ def process_apks(apkcache, repodir, knownapks, use_date_from_apk=False):
|
||||||
|
|
||||||
for icon_dir in get_all_icon_dirs(repodir):
|
for icon_dir in get_all_icon_dirs(repodir):
|
||||||
if os.path.exists(icon_dir):
|
if os.path.exists(icon_dir):
|
||||||
if options.clean:
|
if options is not None and options.clean:
|
||||||
shutil.rmtree(icon_dir)
|
shutil.rmtree(icon_dir)
|
||||||
os.makedirs(icon_dir)
|
os.makedirs(icon_dir)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue