From 9ac7dfe452d6ccffbe49e9df53977d62dcb98934 Mon Sep 17 00:00:00 2001 From: FC Stegerman Date: Thu, 1 Jun 2023 20:23:00 +0200 Subject: [PATCH 1/2] update: fix regression for ArchivePolicy: 0 * https://gitlab.com/fdroid/fdroidserver/-/merge_requests/920#note_1413338920 * https://gitlab.com/fdroid/fdroidserver/-/merge_requests/920#note_1413344025 --- fdroidserver/update.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fdroidserver/update.py b/fdroidserver/update.py index 1fb020ea..86070c67 100644 --- a/fdroidserver/update.py +++ b/fdroidserver/update.py @@ -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 From d96de4d8c282a1ac29ee07d63bda61b6f5064634 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 1 Jun 2023 20:26:42 +0200 Subject: [PATCH 2/2] update: test archive_old_apks() with ArchivePolicy: 0 --- tests/update.TestCase | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/update.TestCase b/tests/update.TestCase index 56ad81a7..2552ce0b 100755 --- a/tests/update.TestCase +++ b/tests/update.TestCase @@ -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'