pmb.helpers.pmaports: cache _glob_apkbuilds results (!1896)

This commit is contained in:
Daniele Debernardi 2020-03-25 22:31:40 +01:00 committed by Oliver Smith
parent f598a7fd41
commit 0c179a5cf9
No known key found for this signature in database
GPG Key ID: 5AE7F5513E0885CB
2 changed files with 11 additions and 1 deletions

View File

@ -131,6 +131,7 @@ def add_cache(args):
"find_aport": {},
"pmb.helpers.package.depends_recurse": {},
"pmb.helpers.package.get": {},
"pmb.helpers.pmaports._glob_apkbuilds": {},
"pmb.helpers.repo.update": repo_update})

View File

@ -13,7 +13,16 @@ import pmb.parse
def _glob_apkbuilds(args, pkgname='*'):
return glob.glob(args.aports + "/**/" + pkgname + "/APKBUILD", recursive=True)
# Try to get a cached result first (we assume, that the aports don't change
# in one pmbootstrap call)
if pkgname in args.cache["pmb.helpers.pmaports._glob_apkbuilds"]:
return args.cache["pmb.helpers.pmaports._glob_apkbuilds"][pkgname]
ret = glob.glob(args.aports + "/**/" + pkgname + "/APKBUILD", recursive=True)
# Save result in cache
args.cache["pmb.helpers.pmaports._glob_apkbuilds"][pkgname] = ret
return ret
def get_list(args, pkgname='*'):