* Don't use substitutes in addToStore().
This commit is contained in:
parent
06434072e7
commit
9df93f30bd
33
src/store.cc
33
src/store.cc
|
@ -181,7 +181,7 @@ bool isInPrefix(const string & path, const string & _prefix)
|
||||||
|
|
||||||
|
|
||||||
string expandId(const FSId & id, const string & target,
|
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);
|
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())
|
if (!ignoreSubstitutes) {
|
||||||
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
|
if (pending.find(id) != pending.end())
|
||||||
already being realised by a substitute. */
|
throw Error(format("id %1% already being expanded") % (string) id);
|
||||||
Strings subs;
|
pending.insert(id);
|
||||||
nixDB.queryStrings(noTxn, dbSubstitutes, id, subs); /* non-existence = ok */
|
|
||||||
|
|
||||||
for (Strings::iterator it = subs.begin(); it != subs.end(); it++) {
|
/* Try to realise the substitutes, but only if this id is not
|
||||||
FSId subId = parseHash(*it);
|
already being realised by a substitute. */
|
||||||
|
Strings subs;
|
||||||
|
nixDB.queryStrings(noTxn, dbSubstitutes, id, subs); /* non-existence = ok */
|
||||||
|
|
||||||
debug(format("trying substitute %1%") % (string) subId);
|
for (Strings::iterator it = subs.begin(); it != subs.end(); it++) {
|
||||||
|
FSId subId = parseHash(*it);
|
||||||
|
|
||||||
realiseSlice(normaliseFState(subId, pending), pending);
|
debug(format("trying substitute %1%") % (string) subId);
|
||||||
|
|
||||||
|
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);
|
throw Error(format("cannot expand id `%1%'") % (string) id);
|
||||||
|
@ -257,7 +261,8 @@ void addToStore(string srcPath, string & dstPath, FSId & id,
|
||||||
|
|
||||||
try {
|
try {
|
||||||
/* !!! should not use the substitutes! */
|
/* !!! should not use the substitutes! */
|
||||||
dstPath = expandId(id, deterministicName ? dstPath : "", nixStore);
|
dstPath = expandId(id, deterministicName ? dstPath : "",
|
||||||
|
nixStore, FSIdSet(), true);
|
||||||
return;
|
return;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,8 @@ bool queryPathId(const string & path, FSId & id);
|
||||||
substitute (since when we build the substitute, we would first try
|
substitute (since when we build the substitute, we would first try
|
||||||
to expand the id... kaboom!). */
|
to expand the id... kaboom!). */
|
||||||
string expandId(const FSId & id, const string & target = "",
|
string expandId(const FSId & id, const string & target = "",
|
||||||
const string & prefix = "/", FSIdSet pending = FSIdSet());
|
const string & prefix = "/", FSIdSet pending = FSIdSet(),
|
||||||
|
bool ignoreSubstitutes = false);
|
||||||
|
|
||||||
/* Copy a file to the nixStore directory and register it in dbRefs.
|
/* Copy a file to the nixStore directory and register it in dbRefs.
|
||||||
Return the hash code of the value. */
|
Return the hash code of the value. */
|
||||||
|
|
Loading…
Reference in a new issue