pmb.helpers.repo.update: refactor cache code (!1726)

Change the cache format from args.cache["offline_msg_shown"] to
args.cache["pmb.helpers.repo.update"]["offline_msg_shown"]. This is in
preparation for saving more data in the cache of
pmb.helpers.repo.update in the next commit.
This commit is contained in:
Oliver Smith 2018-12-11 07:40:43 +01:00
parent a874baa037
commit fa7860c8f6
2 changed files with 6 additions and 4 deletions

View File

@ -130,15 +130,16 @@ def add_shortcuts(args):
def add_cache(args):
""" Add a caching dict (caches parsing of files etc. for the current
session) """
repo_update = {"offline_msg_shown": False}
setattr(args, "cache", {"apkindex": {},
"apkbuild": {},
"apk_min_version_checked": [],
"apk_repository_list_updated": [],
"built": {},
"find_aport": {},
"offline_msg_shown": False,
"pmb.helpers.package.depends_recurse": {},
"pmb.helpers.package.get": {}})
"pmb.helpers.package.get": {},
"pmb.helpers.repo.update": repo_update})
def add_deviceinfo(args):

View File

@ -120,10 +120,11 @@ def update(args, arch=None, force=False, existing_only=False):
:returns: True when files have been downloaded, False otherwise
"""
# Skip in offline mode, only show once
cache_key = "pmb.helpers.repo.update"
if args.offline:
if not args.cache["offline_msg_shown"]:
if not args.cache[cache_key]["offline_msg_shown"]:
logging.info("NOTE: skipping package index update (offline mode)")
args.cache["offline_msg_shown"] = True
args.cache[cache_key]["offline_msg_shown"] = True
return False
# Architectures and retention time