Cache online_repo results indefinitely, but allow force reload
This commit is contained in:
parent
261f237dc7
commit
7dd02f0e2a
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user