forked from Mirror/pmbootstrap
helpers: repo: drop cache key in update (MR 2344)
Simplify the caching here and use logging.warn_once. Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
parent
55c912d410
commit
fce06843fc
2 changed files with 2 additions and 13 deletions
|
@ -293,5 +293,4 @@ def lookup(key):
|
||||||
"""
|
"""
|
||||||
cache: dict[str, Any] = {
|
cache: dict[str, Any] = {
|
||||||
"apkindex": {},
|
"apkindex": {},
|
||||||
"pmb.helpers.repo.update": {"404": [], "offline_msg_shown": False},
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,11 +142,8 @@ def update(arch: Optional[Arch] = None, force=False, existing_only=False):
|
||||||
:returns: True when files have been downloaded, False otherwise
|
:returns: True when files have been downloaded, False otherwise
|
||||||
"""
|
"""
|
||||||
# Skip in offline mode, only show once
|
# Skip in offline mode, only show once
|
||||||
cache_key = "pmb.helpers.repo.update"
|
|
||||||
if get_context().offline:
|
if get_context().offline:
|
||||||
if not pmb.helpers.other.cache[cache_key]["offline_msg_shown"]:
|
logging.warn_once("NOTE: skipping package index update (offline mode)")
|
||||||
logging.info("NOTE: skipping package index update (offline mode)")
|
|
||||||
pmb.helpers.other.cache[cache_key]["offline_msg_shown"] = True
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Architectures and retention time
|
# Architectures and retention time
|
||||||
|
@ -168,11 +165,7 @@ def update(arch: Optional[Arch] = None, force=False, existing_only=False):
|
||||||
|
|
||||||
# Find update reason, possibly skip non-existing or known 404 files
|
# Find update reason, possibly skip non-existing or known 404 files
|
||||||
reason = None
|
reason = None
|
||||||
if url_full in pmb.helpers.other.cache[cache_key]["404"]:
|
if not os.path.exists(apkindex):
|
||||||
# We already attempted to download this file once in this
|
|
||||||
# session
|
|
||||||
continue
|
|
||||||
elif not os.path.exists(apkindex):
|
|
||||||
if existing_only:
|
if existing_only:
|
||||||
continue
|
continue
|
||||||
reason = "file does not exist yet"
|
reason = "file does not exist yet"
|
||||||
|
@ -204,9 +197,6 @@ def update(arch: Optional[Arch] = None, force=False, existing_only=False):
|
||||||
for i, (url, target) in enumerate(outdated.items()):
|
for i, (url, target) in enumerate(outdated.items()):
|
||||||
pmb.helpers.cli.progress_print(i / len(outdated))
|
pmb.helpers.cli.progress_print(i / len(outdated))
|
||||||
temp = pmb.helpers.http.download(url, "APKINDEX", False, logging.DEBUG, True)
|
temp = pmb.helpers.http.download(url, "APKINDEX", False, logging.DEBUG, True)
|
||||||
if not temp:
|
|
||||||
pmb.helpers.other.cache[cache_key]["404"].append(url)
|
|
||||||
continue
|
|
||||||
target_folder = os.path.dirname(target)
|
target_folder = os.path.dirname(target)
|
||||||
if not os.path.exists(target_folder):
|
if not os.path.exists(target_folder):
|
||||||
pmb.helpers.run.root(["mkdir", "-p", target_folder])
|
pmb.helpers.run.root(["mkdir", "-p", target_folder])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue