Fix error message and avoid recalculation

This commit is contained in:
John Ericson 2020-08-01 16:22:50 +00:00
parent bc165e28ae
commit c4ada76e86

View file

@ -203,8 +203,8 @@ std::optional<Hash> Input::getNarHash() const
if (auto s = maybeGetStrAttr(attrs, "narHash")) { if (auto s = maybeGetStrAttr(attrs, "narHash")) {
auto hash = s->empty() ? Hash(htSHA256) : Hash::parseSRI(*s); auto hash = s->empty() ? Hash(htSHA256) : Hash::parseSRI(*s);
if (hash.type != htSHA256) if (hash.type != htSHA256)
throw UsageError("narHash must be specified with SRI notation"); throw UsageError("narHash must use SHA-256");
return newHashAllowEmpty(*s, htSHA256); return hash;
} }
return {}; return {};
} }