Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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) {