From 7dd02f0e2aeac58dee6ae1889046ce15a54151be Mon Sep 17 00:00:00 2001 From: Disassembler Date: Fri, 3 Apr 2020 19:42:06 +0200 Subject: [PATCH] Cache online_repo results indefinitely, but allow force reload --- usr/lib/python3.8/spoc/repo_online.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/usr/lib/python3.8/spoc/repo_online.py b/usr/lib/python3.8/spoc/repo_online.py index 3f7d66a..e20bf89 100644 --- a/usr/lib/python3.8/spoc/repo_online.py +++ b/usr/lib/python3.8/spoc/repo_online.py @@ -86,13 +86,10 @@ def unpack_archive(archive_path, destination, expected_hash, observer): os.unlink(archive_path) data = None -mtime = 0 -def load(): +def load(force=False): global data - global mtime - # Cache the result for 10 seconds - if mtime < time.time()-10: + if not data or force: with requests.Session() as session: resource = session.get(ONLINE_REPO_URL, timeout=5) resource.raise_for_status() @@ -102,7 +99,6 @@ def load(): packages_sig = resource.content get_public_key().verify(packages_sig, packages, ec.ECDSA(hashes.SHA512())) data = json.loads(packages.decode()) - mtime = time.time() def get_entries(entry_type): load()