about summary refs log tree commit diff
path: root/src/libstore/build.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2009-03-28T20·51+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2009-03-28T20·51+0000
commit6e946c8e72e0fd2baa58cab484a34debd2ae906d (patch)
treed088a2a99968dcf29d4dee95d06e229abe8faf3b /src/libstore/build.cc
parentc7152c8f97d01dda4eeb70869a0d28cc9a04df1f (diff)
* Scan for references and compute the SHA-256 hash of the output in
  one pass.  This halves the amount of I/O.

Diffstat (limited to 'src/libstore/build.cc')
-rw-r--r--src/libstore/build.cc20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index 12061bee78..6c24a2746d 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -1864,15 +1864,17 @@ void DerivationGoal::computeClosure()
         /* Get rid of all weird permissions. */
 	canonicalisePathMetaData(path);
 
-	/* For this output path, find the references to other paths contained
-	   in it. */
-        PathSet references = scanForReferences(path, allPaths);
+	/* For this output path, find the references to other paths
+	   contained in it.  Compute the SHA-256 NAR hash at the same
+	   time.  The hash is stored in the database so that we can
+	   verify later on whether nobody has messed with the store. */
+        Hash hash;
+        PathSet references = scanForReferences(path, allPaths, hash);
+        contentHashes[path] = hash;
 
         /* For debugging, print out the referenced and unreferenced
            paths. */
-        for (PathSet::iterator i = inputPaths.begin();
-             i != inputPaths.end(); ++i)
-        {
+        foreach (PathSet::iterator, i, inputPaths) {
             PathSet::iterator j = references.find(*i);
             if (j == references.end())
                 debug(format("unreferenced input: `%1%'") % *i);
@@ -1892,12 +1894,6 @@ void DerivationGoal::computeClosure()
                 if (allowed.find(*i) == allowed.end())
                     throw BuildError(format("output is not allowed to refer to path `%1%'") % *i);
         }
-        
-        /* Hash the contents of the path.  The hash is stored in the
-           database so that we can verify later on whether nobody has
-           messed with the store.  !!! inefficient: it would be nice
-           if we could combine this with filterReferences(). */
-        contentHashes[path] = hashPath(htSHA256, path);
     }
 
     /* Register each output path as valid, and register the sets of