1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-11-12 12:25:02 -05:00

do not register an already registered db

This commit is contained in:
Aurelien Foret 2005-05-02 17:54:44 +00:00
parent a53bf50189
commit a93521aca3

View File

@ -148,13 +148,28 @@ int alpm_get_option(unsigned char parm, long *data)
pmdb_t *alpm_db_register(char *treename)
{
pmdb_t *db;
int found = 0;
/* Sanity checks */
ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, NULL));
ASSERT(treename != NULL && strlen(treename) != 0, RET_ERR(PM_ERR_WRONG_ARGS, NULL));
/* ORE
check if the db if already registered */
if(strcmp(treename, "local") == 0) {
if(handle->db_local != NULL) {
found = 1;
}
} else {
PMList *i;
for(i = handle->dbs_sync; i && !found; i = i->next) {
pmdb_t *sdb = i->data;
if(strcmp(treename, sdb->treename) == 0) {
found = 1;
}
}
}
if(found) {
RET_ERR(PM_ERR_DB_NOT_NULL, NULL);
}
db = db_open(handle->root, handle->dbpath, treename);
if(db == NULL) {