Add assert for replaced storePath

This commit is contained in:
Matthew Bauer 2020-06-17 14:04:46 -04:00
parent 7bd88cc1dc
commit 8974755d19
3 changed files with 16 additions and 2 deletions

View file

@ -4409,8 +4409,11 @@ void SubstitutionGoal::tryNext()
subs.pop_front();
auto subPath = storePath;
if (ca && (hasPrefix(*ca, "fixed:") || hasPrefix(*ca, "text:")))
if (ca && (hasPrefix(*ca, "fixed:") || hasPrefix(*ca, "text:"))) {
subPath = sub->makeFixedOutputPathFromCA(storePath.name(), *ca);
if (sub->storeDir == worker.store.storeDir)
assert(subPath == storePath);
}
try {
// FIXME: make async
@ -4535,8 +4538,11 @@ void SubstitutionGoal::tryToRun()
PushActivity pact(act.id);
auto subPath = storePath;
if (ca && (hasPrefix(*ca, "fixed:") || hasPrefix(*ca, "text:")))
if (ca && (hasPrefix(*ca, "fixed:") || hasPrefix(*ca, "text:"))) {
subPath = sub->makeFixedOutputPathFromCA(storePath.name(), *ca);
if (sub->storeDir == worker.store.storeDir)
assert(subPath == storePath);
}
copyStorePath(ref<Store>(sub), ref<Store>(worker.store.shared_from_this()),
subPath, repair, sub->isTrusted ? NoCheckSigs : CheckSigs);

View file

@ -853,6 +853,8 @@ void LocalStore::querySubstitutablePathInfos(const StorePathSet & paths,
// recompute store path so that we can use a different store root
if (ca != pathsCA.end() && (hasPrefix(ca->second, "fixed:") || hasPrefix(ca->second, "text:"))) {
subPath = makeFixedOutputPathFromCA(path.name(), ca->second);
if (sub->storeDir == storeDir)
assert(subPath == path);
if (subPath != path)
debug("replaced path '%s' with '%s' for substituter '%s'", printStorePath(path), sub->printStorePath(subPath), sub->getUri());
} else if (sub->storeDir != storeDir) continue;

View file

@ -598,6 +598,8 @@ void copyStorePath(ref<Store> srcStore, ref<Store> dstStore,
if (info->isContentAddressed(*srcStore)) {
auto info2 = make_ref<ValidPathInfo>(*info);
info2->path = dstStore->makeFixedOutputPathFromCA(info->path.name(), info->ca);
if (dstStore->storeDir == srcStore->storeDir)
assert(info->path == info2->path);
info = info2;
}
@ -670,6 +672,8 @@ void copyPaths(ref<Store> srcStore, ref<Store> dstStore, const StorePathSet & st
auto storePathForDst = storePath;
if (info->isContentAddressed(*srcStore)) {
storePathForDst = dstStore->makeFixedOutputPathFromCA(storePath.name(), info->ca);
if (dstStore->storeDir == srcStore->storeDir)
assert(storePathForDst == storePath);
if (storePathForDst != storePath)
debug("replaced path '%s' to '%s' for substituter '%s'", srcStore->printStorePath(storePath), dstStore->printStorePath(storePathForDst), dstStore->getUri());
}
@ -695,6 +699,8 @@ void copyPaths(ref<Store> srcStore, ref<Store> dstStore, const StorePathSet & st
auto storePathForDst = storePath;
if (info->isContentAddressed(*srcStore)) {
storePathForDst = dstStore->makeFixedOutputPathFromCA(storePath.name(), info->ca);
if (dstStore->storeDir == srcStore->storeDir)
assert(storePathForDst == storePath);
if (storePathForDst != storePath)
debug("replaced path '%s' to '%s' for substituter '%s'", srcStore->printStorePath(storePath), dstStore->printStorePath(storePathForDst), dstStore->getUri());
}