update:archive_old_apks: handle apps with no CVC

If an app doesn't have a CVC, we can just skip any special archive
handling.
Also rename weirdly named `res` to `apkList`.
This commit is contained in:
Marcus Hoffmann 2020-06-03 21:41:28 +02:00
parent ee162d9e62
commit ee4ee85cbd

View file

@ -2009,19 +2009,19 @@ def make_categories_txt(repodir, categories):
def archive_old_apks(apps, apks, archapks, repodir, archivedir, defaultkeepversions):
def filter_apk_list_sorted(apk_list):
res = []
apkList = []
currentVersionApk = None
for apk in apk_list:
if apk['packageName'] == appid:
if apk['versionCode'] == common.version_code_string_to_int(app.CurrentVersionCode):
currentVersionApk = apk
continue
res.append(apk)
if app.CurrentVersionCode is not None:
if apk['versionCode'] == common.version_code_string_to_int(app.CurrentVersionCode):
currentVersionApk = apk
continue
apkList.append(apk)
# Sort the apk list by version code. First is highest/newest.
sorted_list = sorted(res, key=lambda apk: apk['versionCode'], reverse=True)
sorted_list = sorted(apkList, key=lambda apk: apk['versionCode'], reverse=True)
if currentVersionApk:
# Insert apk which corresponds to currentVersion at the front
sorted_list.insert(0, currentVersionApk)