chore(3p/nix/hash): prefer StatusOr over throwing constructor
The use of `unwrap_throw` can be used as a later grep target. Change-Id: I8c54ed90c4289f07aecb8a1393dd10204c8bce4e Reviewed-on: https://cl.tvl.fyi/c/depot/+/1493 Reviewed-by: glittershark <grfn@gws.fyi> Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
This commit is contained in:
parent
2a292c71f4
commit
1cbffe21f3
15 changed files with 97 additions and 49 deletions
|
@ -64,19 +64,25 @@ void builtinFetchurl(const BasicDerivation& drv, const std::string& netrcData) {
|
|||
|
||||
/* Try the hashed mirrors first. */
|
||||
if (getAttr("outputHashMode") == "flat") {
|
||||
for (auto hashedMirror : settings.hashedMirrors.get()) {
|
||||
try {
|
||||
if (!absl::EndsWith(hashedMirror, "/")) {
|
||||
hashedMirror += '/';
|
||||
auto hash_ = Hash::deserialize(getAttr("outputHash"),
|
||||
parseHashType(getAttr("outputHashAlgo")));
|
||||
if (hash_.ok()) {
|
||||
auto h = *hash_;
|
||||
for (auto hashedMirror : settings.hashedMirrors.get()) {
|
||||
try {
|
||||
if (!absl::EndsWith(hashedMirror, "/")) {
|
||||
hashedMirror += '/';
|
||||
}
|
||||
fetch(hashedMirror + printHashType(h.type) + "/" +
|
||||
h.to_string(Base16, false));
|
||||
return;
|
||||
} catch (Error& e) {
|
||||
LOG(ERROR) << e.what();
|
||||
}
|
||||
auto ht = parseHashType(getAttr("outputHashAlgo"));
|
||||
auto h = Hash(getAttr("outputHash"), ht);
|
||||
fetch(hashedMirror + printHashType(h.type) + "/" +
|
||||
h.to_string(Base16, false));
|
||||
return;
|
||||
} catch (Error& e) {
|
||||
LOG(ERROR) << e.what();
|
||||
}
|
||||
} else {
|
||||
LOG(ERROR) << "checking mirrors for '" << mainUrl
|
||||
<< "': " << hash_.status().ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue