From 4e396216013f1e1b5a34dcb11f9c46b489eb9981 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Fri, 24 Feb 2017 10:28:00 +0100 Subject: [PATCH] provide warning if config items will not preserve order If a group of items are enclosed in {}, then that will be a Python set, which does not preserve order. To preserve order, the data must be either a tuple () or list []. --- fdroidserver/common.py | 6 ++++++ tests/run-tests | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/fdroidserver/common.py b/fdroidserver/common.py index 5e0419b0..5321b7b6 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -221,6 +221,12 @@ def read_config(opts, config_file='config.py'): logging.critical("Missing config file - is this a repo directory?") sys.exit(2) + for k in ('mirrors', 'install_list', 'uninstall_list', 'serverwebroot', 'servergitroot'): + if k in config: + if not type(config[k]) in (str, list, tuple): + logging.warn('"' + k + '" will be in random order!' + + ' Use () or [] brackets if order is important!') + # smartcardoptions must be a list since its command line args for Popen if 'smartcardoptions' in config: config['smartcardoptions'] = config['smartcardoptions'].split(' ') diff --git a/tests/run-tests b/tests/run-tests index 8a9b500a..14dcfd1a 100755 --- a/tests/run-tests +++ b/tests/run-tests @@ -131,7 +131,7 @@ cd $REPOROOT $fdroid init sed -i.tmp 's,^ *repo_description.*,repo_description = """获取已安装在您的设备上的应用的,' config.py -echo "mirrors = {'https://foo.bar/fdroid', 'http://secret.onion/fdroid'}" >> config.py +echo "mirrors = ('https://foo.bar/fdroid', 'http://secret.onion/fdroid')" >> config.py mkdir metadata cp $WORKSPACE/tests/urzip.apk repo/ cp $WORKSPACE/tests/metadata/info.guardianproject.urzip.txt metadata/