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
10
third_party/nix/src/nix-store/nix-store.cc
vendored
10
third_party/nix/src/nix-store/nix-store.cc
vendored
|
|
@ -256,8 +256,11 @@ static void opPrintFixedPath(Strings opFlags, Strings opArgs) {
|
|||
std::string hash = *i++;
|
||||
std::string name = *i++;
|
||||
|
||||
cout << format("%1%\n") %
|
||||
store->makeFixedOutputPath(recursive, Hash(hash, hashAlgo), name);
|
||||
auto hash_ = Hash::deserialize(hash, hashAlgo);
|
||||
Hash::unwrap_throw(hash_);
|
||||
|
||||
cout << absl::StrCat(store->makeFixedOutputPath(recursive, *hash_, name),
|
||||
"\n");
|
||||
}
|
||||
|
||||
static PathSet maybeUseOutputs(const Path& storePath, bool useOutput,
|
||||
|
|
@ -1116,7 +1119,8 @@ static void opServe(Strings opFlags, Strings opArgs) {
|
|||
if (!info.deriver.empty()) {
|
||||
store->assertStorePath(info.deriver);
|
||||
}
|
||||
info.narHash = Hash(readString(in), htSHA256);
|
||||
auto hash_ = Hash::deserialize(readString(in), htSHA256);
|
||||
info.narHash = Hash::unwrap_throw(hash_);
|
||||
info.references = readStorePaths<PathSet>(*store, in);
|
||||
in >> info.registrationTime >> info.narSize >> info.ultimate;
|
||||
info.sigs = readStrings<StringSet>(in);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue