Implemented a cache to get pkg dicts from metadir.
This improves xbps-pkgdb -a marginally, but still seems to be a bit slow.
This commit is contained in:
37
lib/plist.c
37
lib/plist.c
@ -264,40 +264,3 @@ xbps_array_replace_dict_by_pattern(prop_array_t array,
|
||||
{
|
||||
return array_replace_dict(array, dict, pattern, true);
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_pkgd_from_metadir(struct xbps_handle *xhp, const char *name)
|
||||
{
|
||||
prop_dictionary_t pkgd, plistd = NULL;
|
||||
const char *savedpkgname;
|
||||
char *plistf;
|
||||
|
||||
assert(name != NULL);
|
||||
|
||||
savedpkgname = name;
|
||||
plistf = xbps_xasprintf("%s/.%s.plist", xhp->metadir, name);
|
||||
|
||||
if (access(plistf, R_OK) == -1) {
|
||||
pkgd = xbps_find_virtualpkg_dict_installed(xhp, name, false);
|
||||
if (pkgd == NULL)
|
||||
pkgd = xbps_find_pkg_dict_installed(xhp, name, false);
|
||||
|
||||
if (pkgd != NULL) {
|
||||
free(plistf);
|
||||
prop_dictionary_get_cstring_nocopy(pkgd,
|
||||
"pkgname", &savedpkgname);
|
||||
plistf = xbps_xasprintf("%s/.%s.plist",
|
||||
xhp->metadir, savedpkgname);
|
||||
}
|
||||
}
|
||||
|
||||
plistd = prop_dictionary_internalize_from_zfile(plistf);
|
||||
free(plistf);
|
||||
if (plistd == NULL) {
|
||||
xbps_dbg_printf(xhp, "cannot read from metadata %s for %s: %s\n",
|
||||
plistf, savedpkgname, strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return plistd;
|
||||
}
|
||||
|
Reference in New Issue
Block a user