mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-14 06:52:39 +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 = [
|
FDROIDORG_MIRRORS = [
|
||||||
{
|
{
|
||||||
'isPrimary': True,
|
'isPrimary': True,
|
||||||
|
|
|
@ -2276,15 +2276,9 @@ def archive_old_apks(apps, apks, archapks, repodir, archivedir, defaultkeepversi
|
||||||
return sorted_list
|
return sorted_list
|
||||||
|
|
||||||
for appid, app in apps.items():
|
for appid, app in apps.items():
|
||||||
|
keepversions = common.calculate_archive_policy(app, defaultkeepversions)
|
||||||
if app.get('ArchivePolicy') is not None:
|
if common.metadata_find_developer_signing_files(appid, app['CurrentVersionCode']):
|
||||||
keepversions = app['ArchivePolicy']
|
keepversions *= 2
|
||||||
else:
|
|
||||||
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)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue