1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-22 07:48:50 -05:00

Bring back db_scan() modifications from pacman 2.9.1

(to cope with .lastupdate files in the db path)
This commit is contained in:
Aurelien Foret 2005-03-16 21:49:18 +00:00
parent e1eff42fe1
commit ad4ab9e50c

View File

@ -141,6 +141,8 @@ void db_rewind(pmdb_t *db)
pmpkg_t *db_scan(pmdb_t *db, char *target, unsigned int inforeq)
{
struct dirent *ent = NULL;
struct stat sbuf;
char path[PATH_MAX];
char name[256];
char *ptr = NULL;
int ret, found = 0;
@ -158,6 +160,11 @@ pmpkg_t *db_scan(pmdb_t *db, char *target, unsigned int inforeq)
continue;
}
strncpy(name, ent->d_name, 255);
/* stat the entry, make sure it's a directory */
snprintf(path, PATH_MAX, "%s/%s", db->path, name);
if(stat(path, &sbuf) || !S_ISDIR(sbuf.st_mode)) {
continue;
}
/* truncate the string at the second-to-last hyphen, */
/* which will give us the package name */
if((ptr = rindex(name, '-'))) {
@ -175,20 +182,20 @@ pmpkg_t *db_scan(pmdb_t *db, char *target, unsigned int inforeq)
}
} else {
/* normal iteration */
int isdir = 0;
while(!isdir) {
ent = readdir(db->dir);
if(ent == NULL) {
return(NULL);
}
if(!strcmp(ent->d_name, ".")) {
ent = readdir(db->dir);
if(ent == NULL) {
return(NULL);
/* stat the entry, make sure it's a directory */
snprintf(path, PATH_MAX, "%s/%s", db->path, ent->d_name);
if(!stat(path, &sbuf) && S_ISDIR(sbuf.st_mode)) {
isdir = 1;
}
}
if(!strcmp(ent->d_name, "..")) {
ent = readdir(db->dir);
if(ent == NULL) {
return(NULL);
if(!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, "..")) {
isdir = 0;
continue;
}
}
}
@ -669,7 +676,7 @@ PMList *db_find_conflicts(pmdb_t *db, PMList *targets, char *root)
}
if(!ok) {
MALLOC(str, 512);
snprintf(str, 512, "%s: exists in filesystem", path);
snprintf(str, 512, "%s: %s: exists in filesystem", p->name, path);
conflicts = pm_list_add(conflicts, str);
}
}