use the cache instead of calling db_scan()

This commit is contained in:
Aurelien Foret 2005-04-24 11:17:39 +00:00
parent 95fac9cdb2
commit 85203ff675

View file

@ -375,14 +375,7 @@ PMList *checkdeps(pmdb_t *db, unsigned char op, PMList *packages)
k = _alpm_db_whatprovides(db, depend.name); k = _alpm_db_whatprovides(db, depend.name);
if(k) { if(k) {
/* grab the first one (there should only really be one, anyway) */ /* grab the first one (there should only really be one, anyway) */
pmpkg_t *p = db_scan(db, ((pmpkg_t *)k->data)->name, INFRQ_DESC); pmpkg_t *p = k->data;
if(p == NULL) {
/* wtf */
_alpm_log(PM_LOG_ERROR, "%s supposedly provides %s, but it was not found in db",
((pmpkg_t *)k->data)->name, depend.name);
FREELISTPTR(k);
continue;
}
if(depend.mod == PM_DEP_MOD_ANY) { if(depend.mod == PM_DEP_MOD_ANY) {
/* accept any version */ /* accept any version */
found = 1; found = 1;
@ -404,8 +397,8 @@ PMList *checkdeps(pmdb_t *db, unsigned char op, PMList *packages)
} }
FREE(ver); FREE(ver);
} }
FREELISTPTR(k);
} }
FREELISTPTR(k);
} }
/* else if still not found... */ /* else if still not found... */
if(!found) { if(!found) {
@ -516,7 +509,7 @@ PMList* removedeps(pmdb_t *db, PMList *targs)
pmpkg_t *dep; pmpkg_t *dep;
int needed = 0; int needed = 0;
splitdep(j->data, &depend); splitdep(j->data, &depend);
dep = db_scan(db, depend.name, INFRQ_DESC | INFRQ_DEPENDS); dep = db_get_pkgfromcache(db, depend.name);
if(pkg_isin(dep, targs)) { if(pkg_isin(dep, targs)) {
continue; continue;
} }
@ -527,17 +520,19 @@ PMList* removedeps(pmdb_t *db, PMList *targs)
} }
/* see if other packages need it */ /* see if other packages need it */
for(k = dep->requiredby; k && !needed; k = k->next) { for(k = dep->requiredby; k && !needed; k = k->next) {
pmpkg_t *dummy = db_scan(db, k->data, INFRQ_DESC); pmpkg_t *dummy = db_get_pkgfromcache(db, k->data);
if(!pkg_isin(dummy, targs)) { if(!pkg_isin(dummy, targs)) {
needed = 1; needed = 1;
} }
} }
if(!needed) { if(!needed) {
char *name;
asprintf(&name, "%s-%s", dep->name, dep->version);
/* add it to the target list */ /* add it to the target list */
pkg_free(dep); db_read(db, name, INFRQ_ALL, dep);
dep = db_scan(db, depend.name, INFRQ_ALL);
newtargs = pm_list_add(newtargs, dep); newtargs = pm_list_add(newtargs, dep);
newtargs = removedeps(db, newtargs); newtargs = removedeps(db, newtargs);
FREE(name);
} }
} }
} }