summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2007-05-07 16:59:19 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2007-05-07 16:59:19 +0000
commite5da9c88039c360065f20cfd513f2fe68430f04a (patch)
treebfd1fa8887feeb2a5f00bb3d65b0825ddfd2ceed
parent30beeb27a9729366cb4a93d602815827a6153d06 (diff)
downloadguix-e5da9c88039c360065f20cfd513f2fe68430f04a.tar.gz
* Create the database directory if it doesn't exist.
-rw-r--r--src/libstore/db.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libstore/db.cc b/src/libstore/db.cc
index c3cdd3232f..657f6b7b4b 100644
--- a/src/libstore/db.cc
+++ b/src/libstore/db.cc
@@ -143,6 +143,15 @@ Database::~Database()
 void openEnv(DbEnv * & env, const string & path, u_int32_t flags)
 {
     try {
+        createDirs(path);
+    } catch (SysError & e) {
+        if (e.errNo == EPERM || e.errNo == EACCES)
+            throw DbNoPermission(format("cannot create the Nix database in `%1%'") % path);
+        else
+            throw;
+    }
+        
+    try {
         env->open(path.c_str(),
             DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_TXN |
             DB_CREATE | flags,