summary refs log tree commit diff
path: root/src/libstore/gc.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2005-03-24 17:46:38 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2005-03-24 17:46:38 +0000
commitc6178f0b038097584cbbac970ebdb3772de27763 (patch)
treef1786c81a1db945ed4f126fc114af62518cc74cd /src/libstore/gc.cc
parentd1487d9015222c33680c7727c31e3b499c620610 (diff)
downloadguix-c6178f0b038097584cbbac970ebdb3772de27763.tar.gz
* Create missing log and temproots directories automatically (reported
  by Rob).

Diffstat (limited to 'src/libstore/gc.cc')
-rw-r--r--src/libstore/gc.cc17
1 files changed, 5 insertions, 12 deletions
diff --git a/src/libstore/gc.cc b/src/libstore/gc.cc
index e1075d0251..7f0b079467 100644
--- a/src/libstore/gc.cc
+++ b/src/libstore/gc.cc
@@ -43,16 +43,6 @@ static int openGCLock(LockType lockType)
 }
 
 
-static void createDirs(const Path & path)
-{
-    if (path == "") return;
-    createDirs(dirOf(path));
-    if (!pathExists(path))
-        if (mkdir(path.c_str(), 0777) == -1)
-            throw SysError(format("creating directory `%1%'") % path);
-}
-
-
 void createSymlink(const Path & link, const Path & target, bool careful)
 {
     /* Create directories up to `gcRoot'. */
@@ -122,8 +112,11 @@ void addTempRoot(const Path & path)
     if (fdTempRoots == -1) {
 
         while (1) {
-            fnTempRoots = (format("%1%/%2%/%3%")
-                % nixStateDir % tempRootsDir % getpid()).str();
+            Path dir = (format("%1%/%2%") % nixStateDir % tempRootsDir).str();
+            createDirs(dir);
+            
+            fnTempRoots = (format("%1%/%2%")
+                % dir % getpid()).str();
 
             AutoCloseFD fdGCLock = openGCLock(ltRead);