summary refs log tree commit diff
path: root/src/libstore
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2007-02-21 16:23:25 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2007-02-21 16:23:25 +0000
commitdc7d59477613e88b18133208f6c8b2f646e66260 (patch)
treed0d2c6be0202a8e79c5ddd5eb955998721d45449 /src/libstore
parent43c4d18c6a4e1a8b129114439718e26c12b49ca8 (diff)
downloadguix-dc7d59477613e88b18133208f6c8b2f646e66260.tar.gz
* importPath(): set the deriver.
* exportPath(): lock the path, use a transaction.

Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/local-store.cc16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index a7c9d58117..ab1f4682ca 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -723,6 +723,13 @@ void LocalStore::exportPath(const Path & path, bool sign,
 {
     assertStorePath(path);
 
+    /* Wrap all of this in a transaction to make sure that we export
+       consistent metadata. */
+    Transaction txn(nixDB);
+    addTempRoot(path);
+    if (!isValidPath(path))
+        throw Error(format("path `%1%' is not valid") % path);
+
     HashAndWriteSink hashAndWriteSink(sink);
     
     dumpPath(path, hashAndWriteSink);
@@ -732,10 +739,10 @@ void LocalStore::exportPath(const Path & path, bool sign,
     writeString(path, hashAndWriteSink);
     
     PathSet references;
-    queryReferences(path, references);
+    nix::queryReferences(txn, path, references);
     writeStringSet(references, hashAndWriteSink);
 
-    Path deriver = queryDeriver(noTxn, path);
+    Path deriver = queryDeriver(txn, path);
     writeString(deriver, hashAndWriteSink);
 
     if (sign) {
@@ -762,6 +769,8 @@ void LocalStore::exportPath(const Path & path, bool sign,
         
     } else
         writeInt(0, hashAndWriteSink);
+
+    txn.commit();
 }
 
 
@@ -862,8 +871,9 @@ Path LocalStore::importPath(bool requireSignature, Source & source)
             Transaction txn(nixDB);
             /* !!! if we were clever, we could prevent the hashPath()
                here. */
+            if (!isValidPath(deriver)) deriver = "";
             registerValidPath(txn, dstPath,
-                hashPath(htSHA256, dstPath), references, "");
+                hashPath(htSHA256, dstPath), references, deriver);
             txn.commit();
         }