Reworked the cache handling to only load DEPENDS info by default

This commit is contained in:
Aurelien Foret 2005-10-08 21:32:14 +00:00
parent 0d6a2edaa8
commit 05ab859eab
4 changed files with 10 additions and 18 deletions

View File

@ -327,8 +327,6 @@ int add_commit(pmtrans_t *trans, pmdb_t *db)
/* we'll need to save some record for backup checks later */
oldpkg = pkg_new();
if(oldpkg) {
STRNCPY(oldpkg->name, local->name, PKG_NAME_LEN);
STRNCPY(oldpkg->version, local->version, PKG_VERSION_LEN);
if(!(local->infolevel & INFRQ_FILES)) {
char name[(PKG_NAME_LEN-1)+1+(PKG_VERSION_LEN-1)+1];
snprintf(name, (PKG_NAME_LEN-1)+1+(PKG_VERSION_LEN-1)+1, "%s-%s", local->name, local->version);

View File

@ -364,8 +364,6 @@ void *alpm_pkg_getinfo(pmpkg_t *pkg, unsigned char parm)
if(pkg->origin == PKG_FROM_CACHE) {
switch(parm) {
/* Desc entry */
/* ORE
not needed: the cache is loaded with DESC and DEPENDS by default
case PM_PKG_NAME:
case PM_PKG_VERSION:
case PM_PKG_DESC:
@ -384,10 +382,10 @@ void *alpm_pkg_getinfo(pmpkg_t *pkg, unsigned char parm)
snprintf(target, (PKG_NAME_LEN-1)+1+(PKG_VERSION_LEN-1)+1, "%s-%s", pkg->name, pkg->version);
db_read(pkg->data, target, INFRQ_DESC, pkg);
}
break;*/
break;
/* Depends entry */
/* ORE
not needed: the cache is loaded with DESC and DEPENDS by default
not needed: the cache is loaded with DEPENDS by default
case PM_PKG_DEPENDS:
case PM_PKG_REQUIREDBY:
case PM_PKG_CONFLICTS:

View File

@ -49,7 +49,7 @@ static int pkg_cmp(const void *p1, const void *p2)
int db_load_pkgcache(pmdb_t *db)
{
pmpkg_t *info;
unsigned char infolevel = INFRQ_DESC|INFRQ_DEPENDS;
unsigned char infolevel = INFRQ_DEPENDS;
if(db == NULL) {
return(-1);

View File

@ -266,6 +266,12 @@ int db_read(pmdb_t *db, char *name, unsigned int inforeq, pmpkg_t *info)
return(-1);
}
if(info->name[0] == 0) {
if(pkg_splitname(name, info->name, info->version) == -1) {
return(-1);
}
}
/* DESC */
if(inforeq & INFRQ_DESC) {
snprintf(path, PATH_MAX, "%s/%s/desc", db->path, name);
@ -279,17 +285,7 @@ int db_read(pmdb_t *db, char *name, unsigned int inforeq, pmpkg_t *info)
break;
}
_alpm_strtrim(line);
if(!strcmp(line, "%NAME%")) {
if(fgets(info->name, sizeof(info->name), fp) == NULL) {
return(-1);
}
_alpm_strtrim(info->name);
} else if(!strcmp(line, "%VERSION%")) {
if(fgets(info->version, sizeof(info->version), fp) == NULL) {
return(-1);
}
_alpm_strtrim(info->version);
} else if(!strcmp(line, "%DESC%")) {
if(!strcmp(line, "%DESC%")) {
if(fgets(info->desc, sizeof(info->desc), fp) == NULL) {
return(-1);
}