summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAurelien Foret <aurelien@archlinux.org>2005-05-02 17:54:44 +0000
committerAurelien Foret <aurelien@archlinux.org>2005-05-02 17:54:44 +0000
commita93521aca3f1446138458d9c24a583121390cdd9 (patch)
tree43bcdd0182fe459b66e786b338a4b646c3e0d79c
parenta53bf5018986ed1bef4958ad56e5dd87266485fd (diff)
do not register an already registered db
-rw-r--r--lib/libalpm/alpm.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c
index 20bb516c..31cfbc56 100644
--- a/lib/libalpm/alpm.c
+++ b/lib/libalpm/alpm.c
@@ -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) {