Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/alpm.c
diff options
context:
space:
mode:
authorAurelien Foret <aurelien@archlinux.org>2006-03-14 22:53:42 +0000
committerAurelien Foret <aurelien@archlinux.org>2006-03-14 22:53:42 +0000
commitad2c7463c9b3ccf35ed40d8fa4cc21309048bdbc (patch)
treebbe2b153c2d9b471b10a41c3179d80ccd7c8ac0a /lib/libalpm/alpm.c
parent80c7f0efcae9ea7d053d8ba58d2f9adbc75c5cd8 (diff)
put back treename in db->path
Diffstat (limited to 'lib/libalpm/alpm.c')
-rw-r--r--lib/libalpm/alpm.c17
1 files changed, 10 insertions, 7 deletions
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);