mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-14 02:06:16 +02:00
Compute new store path correctly
This commit is contained in:
parent
1c55f16a16
commit
2f2ac850b5
1 changed files with 21 additions and 12 deletions
|
@ -859,20 +859,29 @@ 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()) {
|
||||||
|
auto ca(ca_->second);
|
||||||
|
if (!hasPrefix(ca, "fixed:"))
|
||||||
continue;
|
continue;
|
||||||
// recompute store path so that we can use a different store path
|
FileIngestionMethod ingestionMethod { ca.compare(6, 2, "r:") == 0 };
|
||||||
path = sub->makeStorePath("output:out", hashString(htSHA256, ca->second), path.name());
|
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;
|
} 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));
|
||||||
infos.insert_or_assign(path.clone(), SubstitutablePathInfo{
|
infos.insert_or_assign(path.clone(), SubstitutablePathInfo{
|
||||||
|
|
Loading…
Reference in a new issue