forked from lix-project/lix
Compute new store path correctly
This commit is contained in:
parent
1c55f16a16
commit
2f2ac850b5
|
@ -859,19 +859,28 @@ void LocalStore::querySubstitutablePathInfos(const StorePathSet & paths,
|
||||||
{
|
{
|
||||||
if (!settings.useSubstitutes) return;
|
if (!settings.useSubstitutes) return;
|
||||||
for (auto & sub : getDefaultSubstituters()) {
|
for (auto & sub : getDefaultSubstituters()) {
|
||||||
for (auto & path_ : paths) {
|
for (auto & path : paths) {
|
||||||
auto path(path_.clone());
|
auto subPath(path.clone());
|
||||||
debug("checking substituter '%s' for path '%s'", sub->getUri(), printStorePath(path));
|
|
||||||
try {
|
|
||||||
auto info = sub->queryPathInfo(path);
|
|
||||||
|
|
||||||
auto ca = pathsCA.find(printStorePath(path));
|
auto ca_ = pathsCA.find(printStorePath(path));
|
||||||
if (info->references.empty() && ca != pathsCA.end()) {
|
// recompute store path so that we can use a different store root
|
||||||
if (!hasPrefix(ca->second, "fixed:"))
|
if (ca_ != pathsCA.end()) {
|
||||||
continue;
|
auto ca(ca_->second);
|
||||||
// recompute store path so that we can use a different store path
|
if (!hasPrefix(ca, "fixed:"))
|
||||||
path = sub->makeStorePath("output:out", hashString(htSHA256, ca->second), path.name());
|
continue;
|
||||||
} else if (sub->storeDir != storeDir) continue;
|
FileIngestionMethod ingestionMethod { ca.compare(6, 2, "r:") == 0 };
|
||||||
|
Hash hash(std::string(ca, ingestionMethod == FileIngestionMethod::Recursive ? 8 : 6));
|
||||||
|
subPath = makeFixedOutputPath(ingestionMethod, hash, path.name());
|
||||||
|
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;
|
||||||
|
|
||||||
|
debug("checking substituter '%s' for path '%s'", sub->getUri(), sub->printStorePath(subPath));
|
||||||
|
try {
|
||||||
|
auto info = sub->queryPathInfo(subPath);
|
||||||
|
|
||||||
|
if (sub->storeDir != storeDir && !info->isContentAddressed(*sub))
|
||||||
|
continue;
|
||||||
|
|
||||||
auto narInfo = std::dynamic_pointer_cast<const NarInfo>(
|
auto narInfo = std::dynamic_pointer_cast<const NarInfo>(
|
||||||
std::shared_ptr<const ValidPathInfo>(info));
|
std::shared_ptr<const ValidPathInfo>(info));
|
||||||
|
|
Loading…
Reference in a new issue