mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-13 22:42:29 +03:00
update: extract archive policy calculation to common
This commit is contained in:
parent
173e45f248
commit
9b59d5cf48
2 changed files with 17 additions and 9 deletions
|
@ -4705,6 +4705,20 @@ def _install_ndk(ndk):
|
|||
)
|
||||
|
||||
|
||||
def calculate_archive_policy(app, default):
|
||||
"""Calculate the archive policy from the metadata and default config."""
|
||||
if app.get('ArchivePolicy') is not None:
|
||||
archive_policy = app['ArchivePolicy']
|
||||
else:
|
||||
archive_policy = default
|
||||
if app.get('VercodeOperation'):
|
||||
archive_policy *= len(app['VercodeOperation'])
|
||||
builds = [build for build in app.Builds if not build.disable]
|
||||
if app.Builds and archive_policy > len(builds):
|
||||
archive_policy = len(builds)
|
||||
return archive_policy
|
||||
|
||||
|
||||
FDROIDORG_MIRRORS = [
|
||||
{
|
||||
'isPrimary': True,
|
||||
|
|
|
@ -2276,15 +2276,9 @@ def archive_old_apks(apps, apks, archapks, repodir, archivedir, defaultkeepversi
|
|||
return sorted_list
|
||||
|
||||
for appid, app in apps.items():
|
||||
|
||||
if app.get('ArchivePolicy') is not None:
|
||||
keepversions = app['ArchivePolicy']
|
||||
else:
|
||||
keepversions = defaultkeepversions
|
||||
if app.get('VercodeOperation'):
|
||||
keepversions *= len(app['VercodeOperation'])
|
||||
if common.metadata_find_developer_signing_files(appid, app['CurrentVersionCode']):
|
||||
keepversions *= 2
|
||||
keepversions = common.calculate_archive_policy(app, defaultkeepversions)
|
||||
if common.metadata_find_developer_signing_files(appid, app['CurrentVersionCode']):
|
||||
keepversions *= 2
|
||||
|
||||
logging.debug(_("Checking archiving for {appid} - apks:{integer}, keepversions:{keep}, archapks:{arch}")
|
||||
.format(appid=appid, integer=len(apks), keep=keepversions, arch=len(archapks)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue