mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-19 21:30:10 +01:00
Set ArchivePolicy based on VercodeOperation/signature
This commit is contained in:
parent
9016bb4ca0
commit
d25995c084
@ -1862,6 +1862,10 @@ def archive_old_apks(apps, apks, archapks, repodir, archivedir, defaultkeepversi
|
|||||||
keepversions = int(app['ArchivePolicy'][:-9])
|
keepversions = int(app['ArchivePolicy'][:-9])
|
||||||
else:
|
else:
|
||||||
keepversions = defaultkeepversions
|
keepversions = defaultkeepversions
|
||||||
|
if app.get('VercodeOperation'):
|
||||||
|
keepversions *= len(app['VercodeOperation'])
|
||||||
|
if common.metadata_find_developer_signing_files(appid, app['CurrentVersionCode']):
|
||||||
|
keepversions *= 2
|
||||||
|
|
||||||
logging.debug(_("Checking archiving for {appid} - apks:{integer}, keepversions:{keep}, archapks:{arch}")
|
logging.debug(_("Checking archiving for {appid} - apks:{integer}, keepversions:{keep}, archapks:{arch}")
|
||||||
.format(appid=appid, integer=len(apks), keep=keepversions, arch=len(archapks)))
|
.format(appid=appid, integer=len(apks), keep=keepversions, arch=len(archapks)))
|
||||||
|
@ -1781,6 +1781,27 @@ class UpdateTest(unittest.TestCase):
|
|||||||
apks, cachechanged = fdroidserver.update.process_apks({}, 'repo', knownapks, False, apps)
|
apks, cachechanged = fdroidserver.update.process_apks({}, 'repo', knownapks, False, apps)
|
||||||
self.assertEqual([], apks)
|
self.assertEqual([], apks)
|
||||||
|
|
||||||
|
def test_archive_old_apks(self):
|
||||||
|
app = fdroidserver.metadata.App()
|
||||||
|
app.id = 'test'
|
||||||
|
app.VercodeOperation = ['%c+1', '%c+2', '%c+3', '%c+4']
|
||||||
|
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:12, archapks:0"
|
||||||
|
])
|
||||||
|
|
||||||
|
app = fdroidserver.metadata.App()
|
||||||
|
app.id = 'org.smssecure.smssecure'
|
||||||
|
app.CurrentVersionCode = 135
|
||||||
|
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 org.smssecure.smssecure - apks:0, keepversions:6, archapks:0"
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
os.chdir(os.path.dirname(__file__))
|
os.chdir(os.path.dirname(__file__))
|
||||||
|
Loading…
Reference in New Issue
Block a user