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

include push install/uninstall requests in index-v1

Since the index-v1 is generated straight from the internal dict, this just
moves the generation earlier, and feeds it into the apps dict.
This commit is contained in:
Hans-Christoph Steiner 2016-12-05 21:06:04 +01:00
parent 6c2cf2ccdd
commit ab7e85c951

View File

@ -1105,11 +1105,24 @@ def make_index(apps, sortedids, apks, repodir, archive):
appsWithPackages[packageName] = newapp
break
make_index_v0(appsWithPackages, apks, repodir, repodict)
make_index_v1(appsWithPackages, apks, repodir, repodict)
requestsdict = dict()
for command in ('install', 'uninstall'):
packageNames = []
key = command + '_list'
if key in config:
if isinstance(config[key], str):
packageNames = [config[key]]
elif all(isinstance(item, str) for item in config[key]):
packageNames = config[key]
else:
raise TypeError('only accepts strings, lists, and tuples')
requestsdict[command] = packageNames
make_index_v0(appsWithPackages, apks, repodir, repodict, requestsdict)
make_index_v1(appsWithPackages, apks, repodir, repodict, requestsdict)
def make_index_v1(apps, packages, repodir, repodict):
def make_index_v1(apps, packages, repodir, repodict, requestsdict):
def _index_encoder_default(obj):
if isinstance(obj, set):
@ -1120,6 +1133,7 @@ def make_index_v1(apps, packages, repodir, repodict):
output = collections.OrderedDict()
output['repo'] = repodict
output['requests'] = requestsdict
appslist = []
output['apps'] = appslist
@ -1184,7 +1198,7 @@ def make_index_v1(apps, packages, repodir, repodict):
os.remove(index_file)
def make_index_v0(apps, apks, repodir, repodict):
def make_index_v0(apps, apks, repodir, repodict, requestsdict):
'''aka index.jar aka index.xml'''
doc = Document()
@ -1231,16 +1245,7 @@ def make_index_v0(apps, apks, repodir, repodict):
root.appendChild(repoel)
for command in ('install', 'uninstall'):
packageNames = []
key = command + '_list'
if key in config:
if isinstance(config[key], str):
packageNames = [config[key]]
elif all(isinstance(item, str) for item in config[key]):
packageNames = config[key]
else:
raise TypeError('only accepts strings, lists, and tuples')
for packageName in packageNames:
for packageName in requestsdict[command]:
element = doc.createElement(command)
root.appendChild(element)
element.setAttribute('packageName', packageName)