From a93521aca3f1446138458d9c24a583121390cdd9 Mon Sep 17 00:00:00 2001 From: Aurelien Foret Date: Mon, 2 May 2005 17:54:44 +0000 Subject: do not register an already registered db --- lib/libalpm/alpm.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'lib/libalpm') 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) { -- cgit v1.2.3-70-g09d2