about summary refs log tree commit diff
path: root/src/store.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2003-08-01T09·01+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2003-08-01T09·01+0000
commit9df93f30bda81ffa3cf040c146347e02d3a56666 (patch)
treeb1dea53b8b6fe191d2624a0c6cff144f240e96f5 /src/store.cc
parent06434072e7860f2eaac9581e979801b7b3493a1e (diff)
* Don't use substitutes in addToStore().
Diffstat (limited to 'src/store.cc')
-rw-r--r--src/store.cc33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/store.cc b/src/store.cc
index 8d424bc590..2facb4cb1a 100644
--- a/src/store.cc
+++ b/src/store.cc
@@ -181,7 +181,7 @@ bool isInPrefix(const string & path, const string & _prefix)
 
 
 string expandId(const FSId & id, const string & target,
-    const string & prefix, FSIdSet pending)
+    const string & prefix, FSIdSet pending, bool ignoreSubstitutes)
 {
     Nest nest(lvlDebug, format("expanding %1%") % (string) id);
 
@@ -221,23 +221,27 @@ string expandId(const FSId & id, const string & target,
         }
     }
 
-    if (pending.find(id) != pending.end())
-        throw Error(format("id %1% already being expanded") % (string) id);
-    pending.insert(id);
+    if (!ignoreSubstitutes) {
+        
+        if (pending.find(id) != pending.end())
+            throw Error(format("id %1% already being expanded") % (string) id);
+        pending.insert(id);
 
-    /* Try to realise the substitutes, but only if this id is not
-       already being realised by a substitute. */
-    Strings subs;
-    nixDB.queryStrings(noTxn, dbSubstitutes, id, subs); /* non-existence = ok */
+        /* Try to realise the substitutes, but only if this id is not
+           already being realised by a substitute. */
+        Strings subs;
+        nixDB.queryStrings(noTxn, dbSubstitutes, id, subs); /* non-existence = ok */
 
-    for (Strings::iterator it = subs.begin(); it != subs.end(); it++) {
-        FSId subId = parseHash(*it);
+        for (Strings::iterator it = subs.begin(); it != subs.end(); it++) {
+            FSId subId = parseHash(*it);
 
-        debug(format("trying substitute %1%") % (string) subId);
+            debug(format("trying substitute %1%") % (string) subId);
 
-        realiseSlice(normaliseFState(subId, pending), pending);
+            realiseSlice(normaliseFState(subId, pending), pending);
+
+            return expandId(id, target, prefix, pending);
+        }
 
-        return expandId(id, target, prefix, pending);
     }
     
     throw Error(format("cannot expand id `%1%'") % (string) id);
@@ -257,7 +261,8 @@ void addToStore(string srcPath, string & dstPath, FSId & id,
 
     try {
         /* !!! should not use the substitutes! */
-        dstPath = expandId(id, deterministicName ? dstPath : "", nixStore);
+        dstPath = expandId(id, deterministicName ? dstPath : "", 
+            nixStore, FSIdSet(), true);
         return;
     } catch (...) {
     }