about summary refs log tree commit diff
path: root/src/store.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2003-07-16T20·00+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2003-07-16T20·00+0000
commit9d56ca219fb7af1c209458f81a8ce35a1b6afd28 (patch)
treef30d9c4f8ed84edaf1d16298ac8dcb2d2b9e2ecc /src/store.cc
parentb9ecadee6e32eddac07d09a228f0dda2b340c7ac (diff)
* Substitute fixes.
Diffstat (limited to 'src/store.cc')
-rw-r--r--src/store.cc27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/store.cc b/src/store.cc
index c8b3bd37f4e5..d75458d8a55b 100644
--- a/src/store.cc
+++ b/src/store.cc
@@ -86,6 +86,7 @@ void copyPath(string src, string dst)
 
 void registerSubstitute(const FSId & srcId, const FSId & subId)
 {
+#if 0
     Strings subs;
     queryListDB(nixDB, dbSubstitutes, srcId, subs); /* non-existence = ok */
 
@@ -95,6 +96,12 @@ void registerSubstitute(const FSId & srcId, const FSId & subId)
     subs.push_back(subId);
     
     setListDB(nixDB, dbSubstitutes, srcId, subs);
+#endif
+
+    /* For now, accept only one substitute per id. */
+    Strings subs;
+    subs.push_back(subId);
+    setListDB(nixDB, dbSubstitutes, srcId, subs);
 }
 
 
@@ -126,6 +133,8 @@ void unregisterPath(const string & _path)
         return;
     FSId id(parseHash(_id));
 
+    delDB(nixDB, dbPath2Id, path);
+
     /* begin transaction */
     
     Strings paths, paths2;
@@ -140,6 +149,7 @@ void unregisterPath(const string & _path)
         setListDB(nixDB, dbId2Paths, id, paths2);
 
     /* end transaction */
+
 }
 
 
@@ -189,32 +199,31 @@ string expandId(const FSId & id, const string & target,
         }
     }
 
-#if 0
     /* Try to realise the substitutes. */
 
     Strings subs;
     queryListDB(nixDB, dbSubstitutes, id, subs); /* non-existence = ok */
 
     for (Strings::iterator it = subs.begin(); it != subs.end(); it++) {
-        realiseSlice(normaliseFState(*it));
+        FSId subId = parseHash(*it);
+        Slice slice = normaliseFState(subId);
+        realiseSlice(slice);
         
-        FState nf = realiseFState(hash2fstate(parseHash(*it)), dummy);
-        string path = fstatePath(nf);
-
-        if (hashPath(path) != hash)
-            throw Error(format("bad substitute in `%1%'") % (string) path);
+        Strings paths = fstatePaths(subId, true);
+        if (paths.size() != 1) 
+            throw Error("substitute created more than 1 path");
+        string path = *(paths.begin());
 
         if (target.empty())
             return path; /* !!! prefix */
         else {
             if (path != target) {
                 copyPath(path, target);
-                registerPath(target, hash);
+                registerPath(target, id);
             }
             return target;
         }
     }
-#endif
     
     throw Error(format("cannot expand id `%1%'") % (string) id);
 }