allow common.get_apk_id() to be used in the API

If a project uses fdroidserver as a library, then just calls
common.get_apk_id(), it will now work.  Before, that project would have had
to include something like `common.config = {}` to avoid a stacktrace.
This commit is contained in:
Hans-Christoph Steiner 2022-04-27 13:18:04 +02:00
parent 9605d4ecad
commit c6dcc82ca4
2 changed files with 20 additions and 3 deletions

View file

@ -2689,9 +2689,11 @@ def get_apk_id(apkfile):
try:
return get_apk_id_androguard(apkfile)
except zipfile.BadZipFile as e:
logging.error(apkfile + ': ' + str(e))
if 'aapt' in config:
if config and 'aapt' in config:
logging.error(apkfile + ': ' + str(e))
return get_apk_id_aapt(apkfile)
else:
raise e
def get_apk_id_androguard(apkfile):