add intermediate variables and clarifying comments (#9274)

* add intermediate variables and clarifying comments

Co-authored-by: Alexander Groleau <alex@proof.construction>
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
This commit is contained in:
Valentin Gagarin 2024-04-12 17:43:35 +02:00 committed by GitHub
parent 5b9cb8b372
commit 13c2005e7d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 7 deletions

View file

@ -2960,16 +2960,25 @@ bool LocalDerivationGoal::isReadDesc(int fd)
StorePath LocalDerivationGoal::makeFallbackPath(OutputNameView outputName)
{
// This is a bogus path type, constructed this way to ensure that it doesn't collide with any other store path
// See doc/manual/src/protocols/store-path.md for details
// TODO: We may want to separate the responsibilities of constructing the path fingerprint and of actually doing the hashing
auto pathType = "rewrite:" + std::string(drvPath.to_string()) + ":name:" + std::string(outputName);
return worker.store.makeStorePath(
"rewrite:" + std::string(drvPath.to_string()) + ":name:" + std::string(outputName),
pathType,
// pass an all-zeroes hash
Hash(HashAlgorithm::SHA256), outputPathName(drv->name, outputName));
}
StorePath LocalDerivationGoal::makeFallbackPath(const StorePath & path)
{
// This is a bogus path type, constructed this way to ensure that it doesn't collide with any other store path
// See doc/manual/src/protocols/store-path.md for details
auto pathType = "rewrite:" + std::string(drvPath.to_string()) + ":" + std::string(path.to_string());
return worker.store.makeStorePath(
"rewrite:" + std::string(drvPath.to_string()) + ":" + std::string(path.to_string()),
pathType,
// pass an all-zeroes hash
Hash(HashAlgorithm::SHA256), path.name());
}

View file

@ -131,12 +131,12 @@ StorePath StoreDirConfig::makeFixedOutputPath(std::string_view name, const Fixed
throw Error("fixed output derivation '%s' is not allowed to refer to other store paths.\nYou may need to use the 'unsafeDiscardReferences' derivation attribute, see the manual for more details.",
name);
}
return makeStorePath("output:out",
hashString(HashAlgorithm::SHA256,
"fixed:out:"
// make a unique digest based on the parameters for creating this store object
auto payload = "fixed:out:"
+ makeFileIngestionPrefix(info.method)
+ info.hash.to_string(HashFormat::Base16, true) + ":"),
name);
+ info.hash.to_string(HashFormat::Base16, true) + ":";
auto digest = hashString(HashAlgorithm::SHA256, payload);
return makeStorePath("output:out", digest, name);
}
}