1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-12-01 06:31:00 +01:00

Add newHashAllowEmpty helper function

This replaces the copy&paste with a helper function in hash.hh.
This commit is contained in:
Matthew Bauer 2020-06-12 10:09:42 -05:00
parent 19aa892f20
commit b260c9ee03
6 changed files with 24 additions and 38 deletions

View file

@ -34,14 +34,9 @@ std::unique_ptr<Input> inputFromAttrs(const Attrs & attrs)
for (auto & inputScheme : *inputSchemes) {
auto res = inputScheme->inputFromAttrs(attrs2);
if (res) {
if (auto narHash = maybeGetStrAttr(attrs, "narHash")) {
if (narHash->empty()) {
res->narHash = Hash(htUnknown);
printError("warning: found empty hash, assuming you wanted '%s'", res->narHash->to_string());
} else
// FIXME: require SRI hash.
res->narHash = Hash(*narHash);
}
if (auto narHash = maybeGetStrAttr(attrs, "narHash"))
// FIXME: require SRI hash.
res->narHash = newHashAllowEmpty(*narHash, htUnknown);
return res;
}
}