Correct FIXMEs in libfetchers

This commit is contained in:
Carlo Nucera 2020-07-01 17:47:15 -04:00
parent c2e7f7a712
commit 274a8136fb
4 changed files with 5 additions and 7 deletions

View file

@ -35,8 +35,7 @@ std::unique_ptr<Input> inputFromAttrs(const Attrs & attrs)
auto res = inputScheme->inputFromAttrs(attrs2);
if (res) {
if (auto narHash = maybeGetStrAttr(attrs, "narHash"))
// FIXME: require SRI hash.
res->narHash = newHashAllowEmpty(*narHash, {});
res->narHash = Hash::fromSRI(*narHash);
return res;
}
}

View file

@ -242,15 +242,13 @@ struct TarballInputScheme : InputScheme
auto hash = input->url.query.find("hash");
if (hash != input->url.query.end()) {
// FIXME: require SRI hash.
input->hash = Hash(hash->second);
input->hash = Hash::fromSRI(hash->second);
input->url.query.erase(hash);
}
auto narHash = input->url.query.find("narHash");
if (narHash != input->url.query.end()) {
// FIXME: require SRI hash.
input->narHash = Hash(narHash->second);
input->narHash = Hash::fromSRI(narHash->second);
input->url.query.erase(narHash);
}

View file

@ -43,7 +43,7 @@ struct Hash
// hash type must be part of string
Hash(std::string_view s);
Hash fromSRI(std::string_view original);
static Hash fromSRI(std::string_view original);
private:
// type must be provided, s must not include <type> prefix

View file

@ -1,5 +1,6 @@
#include "lazy.hh"
#include "util.hh"
#include "hash.hh"
#include "affinity.hh"
#include "sync.hh"
#include "finally.hh"