diff options
author | Matthew Bauer <mjbauer95@gmail.com> | 2020-06-12 10:09:42 -0500 |
---|---|---|
committer | Matthew Bauer <mjbauer95@gmail.com> | 2020-06-12 10:11:16 -0500 |
commit | b260c9ee0325d7a4c78d91e47bd6e2afbde16e28 (patch) | |
tree | 176d906367d85d75e96089ce067b776fe232eacf /src/libfetchers/tarball.cc | |
parent | 19aa892f2064d437d32a3c12758d6a623b7ae8e5 (diff) |
Add newHashAllowEmpty helper function
This replaces the copy&paste with a helper function in hash.hh.
Diffstat (limited to 'src/libfetchers/tarball.cc')
-rw-r--r-- | src/libfetchers/tarball.cc | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/src/libfetchers/tarball.cc b/src/libfetchers/tarball.cc index e4dafec0b..937f86bc6 100644 --- a/src/libfetchers/tarball.cc +++ b/src/libfetchers/tarball.cc @@ -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; } |