1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-20 09:19:36 +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

@ -263,14 +263,8 @@ struct TarballInputScheme : InputScheme
throw Error("unsupported tarball input attribute '%s'", name);
auto input = std::make_unique<TarballInput>(parseURL(getStrAttr(attrs, "url")));
if (auto hash = maybeGetStrAttr(attrs, "hash")) {
if (hash->empty()) {
input->hash = Hash(htUnknown);
printError("warning: found empty hash, assuming you wanted '%s'", input->hash->to_string());
} else
// FIXME: require SRI hash.
input->hash = Hash(*hash);
}
if (auto hash = maybeGetStrAttr(attrs, "hash"))
input->hash = newHashAllowEmpty(*hash, htUnknown);
return input;
}