From 723873456d96bbb068b53d7920c82179e0097dac Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Tue, 7 Mar 2023 21:44:28 +0100 Subject: [PATCH] versioned download_repo_index_v1() to be future proof --- fdroidserver/__init__.py | 2 ++ fdroidserver/index.py | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/fdroidserver/__init__.py b/fdroidserver/__init__.py index 72a9c38d..9f0889ff 100644 --- a/fdroidserver/__init__.py +++ b/fdroidserver/__init__.py @@ -36,9 +36,11 @@ from fdroidserver.common import (verify_apk_signature, verify_apk_signature # NOQA: B101 generate_keystore # NOQA: B101 from fdroidserver.index import (download_repo_index, + download_repo_index_v1, get_mirror_service_urls, make as make_index) # NOQA: E402 download_repo_index # NOQA: B101 +download_repo_index_v1 # NOQA: B101 get_mirror_service_urls # NOQA: B101 make_index # NOQA: B101 from fdroidserver.update import (process_apk, diff --git a/fdroidserver/index.py b/fdroidserver/index.py index ebf8fe64..955d9486 100644 --- a/fdroidserver/index.py +++ b/fdroidserver/index.py @@ -1476,7 +1476,17 @@ def get_mirror_service_urls(url): def download_repo_index(url_str, etag=None, verify_fingerprint=True, timeout=600): - """Download and verifies index file, then returns its data. + """Download and verifies index v1 file, then returns its data. + + Use the versioned functions to be sure you are getting the + expected data format. + + """ + return download_repo_index_v1(url_str, etag, verify_fingerprint, timeout) + + +def download_repo_index_v1(url_str, etag=None, verify_fingerprint=True, timeout=600): + """Download and verifies index v1 file, then returns its data. Downloads the repository index from the given :param url_str and verifies the repository's fingerprint if :param verify_fingerprint @@ -1489,7 +1499,7 @@ def download_repo_index(url_str, etag=None, verify_fingerprint=True, timeout=600 Returns ------- A tuple consisting of: - - The index in JSON format or None if the index did not change + - The index in JSON v1 format or None if the index did not change - The new eTag as returned by the HTTP request """