From: Hans-Christoph Steiner Date: Mon, 5 Dec 2016 20:06:04 +0000 (+0100) Subject: include push install/uninstall requests in index-v1 X-Git-Tag: 0.8~98^2~6 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=ab7e85c951b1c25a6c13b21a125436704c908b7e;p=fdroidserver.git 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. --- diff --git a/fdroidserver/update.py b/fdroidserver/update.py index ece1d2bf..05a11678 100644 --- a/fdroidserver/update.py +++ b/fdroidserver/update.py @@ -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)