1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-11-04 14:30:11 +01:00

Merge branch 'fix-ArchivePolicy-0' into 'master'

update: fix regression for ArchivePolicy: 0

See merge request fdroid/fdroidserver!1371
This commit is contained in:
Hans-Christoph Steiner 2023-06-01 18:59:14 +00:00
commit a1c4f803de
2 changed files with 13 additions and 2 deletions

View File

@ -176,7 +176,7 @@ def status_update_json(apps, apks):
validapks = 0
if app.get('Disabled'):
output['disabled'].append(appid)
elif app["ArchivePolicy"] == 0:
elif app.get("ArchivePolicy") == 0:
output['archivePolicy0'].append(appid)
else:
for build in app.get('Builds', []):
@ -1876,7 +1876,7 @@ def archive_old_apks(apps, apks, archapks, repodir, archivedir, defaultkeepversi
for appid, app in apps.items():
if app.get('ArchivePolicy'):
if app.get('ArchivePolicy') is not None:
keepversions = app['ArchivePolicy']
else:
keepversions = defaultkeepversions

View File

@ -1757,6 +1757,17 @@ class UpdateTest(unittest.TestCase):
apks, cachechanged = fdroidserver.update.process_apks({}, 'repo', knownapks, False, apps)
self.assertEqual([], apks)
def test_archive_old_apks_ArchivePolicy_0(self):
app = fdroidserver.metadata.App()
app.id = 'test'
app.ArchivePolicy = 0
apps = {app.id: app}
with self.assertLogs(level='DEBUG') as cm:
fdroidserver.update.archive_old_apks(apps, [], [], '', '', 3)
self.assertEqual(cm.output, [
"DEBUG:root:Checking archiving for test - apks:0, keepversions:0, archapks:0"
])
def test_archive_old_apks(self):
app = fdroidserver.metadata.App()
app.id = 'test'