index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Aurelien Foret <aurelien@archlinux.org> | 2006-03-14 22:53:42 +0000 |
---|---|---|
committer | Aurelien Foret <aurelien@archlinux.org> | 2006-03-14 22:53:42 +0000 |
commit | ad2c7463c9b3ccf35ed40d8fa4cc21309048bdbc (patch) | |
tree | bbe2b153c2d9b471b10a41c3179d80ccd7c8ac0a /lib/libalpm/alpm.c | |
parent | 80c7f0efcae9ea7d053d8ba58d2f9adbc75c5cd8 (diff) |
-rw-r--r-- | lib/libalpm/alpm.c | 17 |
diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c index 18021fba..dddeaeff 100644 --- a/lib/libalpm/alpm.c +++ b/lib/libalpm/alpm.c @@ -164,6 +164,7 @@ pmdb_t *alpm_db_register(char *treename) struct stat buf; pmdb_t *db; int found = 0; + char path[PATH_MAX]; /* Sanity checks */ ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, NULL)); @@ -190,18 +191,20 @@ pmdb_t *alpm_db_register(char *treename) _alpm_log(PM_LOG_FLOW1, "registering database '%s'", treename); - db = _alpm_db_new(handle->root, handle->dbpath, treename); - if(db == NULL) { - return(NULL); - } - /* make sure the database directory exists */ - if(stat(db->path, &buf) != 0 || !S_ISDIR(buf.st_mode)) { - if(_alpm_makepath(db->path) != 0) { + snprintf(path, PATH_MAX, "%s%s/%s", handle->root, handle->dbpath, treename); + if(stat(path, &buf) != 0 || !S_ISDIR(buf.st_mode)) { + _alpm_log(PM_LOG_FLOW1, "database directory '%s' does not exist -- try creating it", path); + if(_alpm_makepath(path) != 0) { RET_ERR(PM_ERR_SYSTEM, NULL); } } + db = _alpm_db_new(handle->root, handle->dbpath, treename); + if(db == NULL) { + return(NULL); + } + _alpm_log(PM_LOG_DEBUG, "opening database '%s'", db->treename); if(_alpm_db_open(db, DB_O_CREATE) == -1) { _alpm_db_free(db); |