forked from lix-project/lix
Parse narHash attribute for all input types
This commit is contained in:
parent
442e665d6d
commit
d4df99a334
|
@ -32,7 +32,12 @@ std::unique_ptr<Input> inputFromAttrs(const Input::Attrs & attrs)
|
||||||
{
|
{
|
||||||
for (auto & inputScheme : *inputSchemes) {
|
for (auto & inputScheme : *inputSchemes) {
|
||||||
auto res = inputScheme->inputFromAttrs(attrs);
|
auto res = inputScheme->inputFromAttrs(attrs);
|
||||||
if (res) return res;
|
if (res) {
|
||||||
|
if (auto narHash = maybeGetStrAttr(attrs, "narHash"))
|
||||||
|
// FIXME: require SRI hash.
|
||||||
|
res->narHash = Hash(*narHash);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
throw Error("input '%s' is unsupported", attrsToJson(attrs));
|
throw Error("input '%s' is unsupported", attrsToJson(attrs));
|
||||||
}
|
}
|
||||||
|
@ -106,8 +111,8 @@ std::pair<Tree, std::shared_ptr<const Input>> Input::fetchTree(ref<Store> store)
|
||||||
assert(input->narHash == tree.info.narHash);
|
assert(input->narHash == tree.info.narHash);
|
||||||
|
|
||||||
if (narHash && narHash != input->narHash)
|
if (narHash && narHash != input->narHash)
|
||||||
throw Error("NAR hash mismatch in input '%s', expected '%s', got '%s'",
|
throw Error("NAR hash mismatch in input '%s' (%s), expected '%s', got '%s'",
|
||||||
to_string(), narHash->to_string(SRI), input->narHash->to_string(SRI));
|
to_string(), tree.actualPath, narHash->to_string(SRI), input->narHash->to_string(SRI));
|
||||||
|
|
||||||
return {std::move(tree), input};
|
return {std::move(tree), input};
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,9 +121,7 @@ struct TarballInputScheme : InputScheme
|
||||||
if (auto hash = maybeGetStrAttr(attrs, "hash"))
|
if (auto hash = maybeGetStrAttr(attrs, "hash"))
|
||||||
// FIXME: require SRI hash.
|
// FIXME: require SRI hash.
|
||||||
input->hash = Hash(*hash);
|
input->hash = Hash(*hash);
|
||||||
if (auto narHash = maybeGetStrAttr(attrs, "narHash"))
|
|
||||||
// FIXME: require SRI hash.
|
|
||||||
input->narHash = Hash(*narHash);
|
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue