about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-12-01T21·00+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-12-01T21·00+0000
commitfcd9900d74b0eb3d57402c448ede2a411133fa46 (patch)
tree642df2be381e3c9b239ca59c170052a43113fa30
parenta824d58b566752b2a89a718fd628053754968d72 (diff)
* Replace read-only calls to addTextToStore.
-rw-r--r--src/libexpr/primops.cc4
-rw-r--r--src/libstore/derivations.cc8
2 files changed, 9 insertions, 3 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index 17a04bc83390..1d0d9c6b2245 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -389,7 +389,9 @@ static Expr primToFile(EvalState & state, const ATermVector & args)
         refs.insert(*i);
     }
     
-    Path storePath = store->addTextToStore(name, contents, refs);
+    Path storePath = readOnlyMode
+        ? computeStorePathForText(name, contents)
+        : store->addTextToStore(name, contents, refs);
 
     /* Note: we don't need to add `context' to the context of the
        result, since `storePath' itself has references to the paths
diff --git a/src/libstore/derivations.cc b/src/libstore/derivations.cc
index d159d47a5e4a..aea95ef31477 100644
--- a/src/libstore/derivations.cc
+++ b/src/libstore/derivations.cc
@@ -1,6 +1,7 @@
 #include "derivations.hh"
 #include "store-api.hh"
 #include "aterm.hh"
+#include "globals.hh"
 
 #include "derivations-ast.hh"
 #include "derivations-ast.cc"
@@ -25,8 +26,11 @@ Path writeDerivation(const Derivation & drv, const string & name)
     /* Note that the outputs of a derivation are *not* references
        (that can be missing (of course) and should not necessarily be
        held during a garbage collection). */
-    return store->addTextToStore(name + drvExtension,
-        atPrint(unparseDerivation(drv)), references);
+    string suffix = name + drvExtension;
+    string contents = atPrint(unparseDerivation(drv));
+    return readOnlyMode
+        ? computeStorePathForText(suffix, contents)
+        : store->addTextToStore(suffix, contents, references);
 }