diff options
author | Kane York <kanepyork@gmail.com> | 2020-07-28T02·57-0700 |
---|---|---|
committer | kanepyork <rikingcoding@gmail.com> | 2020-08-01T01·15+0000 |
commit | 1cbffe21f3284fbad10b4ca27b0d8381bd554ff3 (patch) | |
tree | 921c90af406f009a660bb82eb40324a459bca7b7 /third_party/nix/src/libexpr | |
parent | 2a292c71f40f3592e33534ee6d63eb2ca5221d5e (diff) |
chore(3p/nix/hash): prefer StatusOr over throwing constructor r/1515
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
Diffstat (limited to 'third_party/nix/src/libexpr')
-rw-r--r-- | third_party/nix/src/libexpr/primops.cc | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/third_party/nix/src/libexpr/primops.cc b/third_party/nix/src/libexpr/primops.cc index c754f0392b89..8e916163b4ec 100644 --- a/third_party/nix/src/libexpr/primops.cc +++ b/third_party/nix/src/libexpr/primops.cc @@ -704,7 +704,8 @@ static void prim_derivationStrict(EvalState& state, const Pos& pos, HashType ht = outputHashAlgo.empty() ? htUnknown : parseHashType(outputHashAlgo); - Hash h(*outputHash, ht); + auto hash_ = Hash::deserialize(*outputHash, ht); + auto h = Hash::unwrap_throw(hash_); Path outPath = state.store->makeFixedOutputPath(outputHashRecursive, h, drvName); @@ -1144,9 +1145,10 @@ static void prim_path(EvalState& state, const Pos& pos, Value** args, } else if (n == "recursive") { recursive = state.forceBool(*attr.second.value, *attr.second.pos); } else if (n == "sha256") { - expectedHash = - Hash(state.forceStringNoCtx(*attr.second.value, *attr.second.pos), - htSHA256); + auto hash_ = Hash::deserialize( + state.forceStringNoCtx(*attr.second.value, *attr.second.pos), + htSHA256); + expectedHash = Hash::unwrap_throw(hash_); } else { throw EvalError( format("unsupported argument '%1%' to 'addPath', at %2%") % @@ -2077,9 +2079,10 @@ void fetch(EvalState& state, const Pos& pos, Value** args, Value& v, request.uri = state.forceStringNoCtx(*attr.second.value, *attr.second.pos); } else if (n == "sha256") { - request.expectedHash = - Hash(state.forceStringNoCtx(*attr.second.value, *attr.second.pos), - htSHA256); + auto hash_ = Hash::deserialize( + state.forceStringNoCtx(*attr.second.value, *attr.second.pos), + htSHA256); + request.expectedHash = Hash::unwrap_throw(hash_); } else if (n == "name") { request.name = state.forceStringNoCtx(*attr.second.value, *attr.second.pos); |