about summary refs log tree commit diff
path: root/src/libstore/store.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2005-03-23T13·07+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2005-03-23T13·07+0000
commit3f236f01ae7e9abe58a591071698a9a9840af7c2 (patch)
treefe2226d88b57ab9362016e610365dd2719f64262 /src/libstore/store.cc
parenta04c62e0c4f0f8d3bd9cda21173a0193be9eda8a (diff)
* `nix-store --register-validity': allow a path to refer to a path
  listed later in the list of new valid paths.

Diffstat (limited to 'src/libstore/store.cc')
-rw-r--r--src/libstore/store.cc50
1 files changed, 37 insertions, 13 deletions
diff --git a/src/libstore/store.cc b/src/libstore/store.cc
index e9d65404400e..5742bbb73870 100644
--- a/src/libstore/store.cc
+++ b/src/libstore/store.cc
@@ -508,24 +508,48 @@ Hash queryPathHash(const Path & path)
 
 
 void registerValidPath(const Transaction & txn,
-    const Path & _path, const Hash & hash, const PathSet & references,
+    const Path & path, const Hash & hash, const PathSet & references,
     const Path & deriver)
 {
-    Path path(canonPath(_path));
-    assertStorePath(path);
+    ValidPathInfo info;
+    info.path = path;
+    info.hash = hash;
+    info.references = references;
+    info.deriver = deriver;
+    ValidPathInfos infos;
+    infos.push_back(info);
+    registerValidPaths(txn, infos);
+}
 
-    debug(format("registering path `%1%'") % path);
-    setHash(txn, path, hash);
 
-    setReferences(txn, path, references);
-    
-    /* Check that all referenced paths are also valid. */
-    for (PathSet::iterator i = references.begin(); i != references.end(); ++i)
-        if (!isValidPathTxn(txn, *i))
-            throw Error(format("cannot register path `%1%' as valid, since its reference `%2%' is invalid")
-                % path % *i);
+void registerValidPaths(const Transaction & txn,
+    const ValidPathInfos & infos)
+{
+    PathSet newPaths;
+    for (ValidPathInfos::const_iterator i = infos.begin();
+         i != infos.end(); ++i)
+        newPaths.insert(i->path);
+        
+    for (ValidPathInfos::const_iterator i = infos.begin();
+         i != infos.end(); ++i)
+    {
+        assertStorePath(i->path);
+
+        debug(format("registering path `%1%'") % i->path);
+        setHash(txn, i->path, i->hash);
 
-    setDeriver(txn, path, deriver);
+        setReferences(txn, i->path, i->references);
+    
+        /* Check that all referenced paths are also valid (or about to
+           become valid). */
+        for (PathSet::iterator j = i->references.begin();
+             j != i->references.end(); ++j)
+            if (!isValidPathTxn(txn, *j) && newPaths.find(*j) == newPaths.end())
+                throw Error(format("cannot register path `%1%' as valid, since its reference `%2%' is invalid")
+                    % i->path % *j);
+
+        setDeriver(txn, i->path, i->deriver);
+    }
 }