From 1cbffe21f3284fbad10b4ca27b0d8381bd554ff3 Mon Sep 17 00:00:00 2001 From: Kane York Date: Mon, 27 Jul 2020 19:57:04 -0700 Subject: 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 Reviewed-by: tazjin Tested-by: BuildkiteCI --- third_party/nix/src/nix-store/nix-store.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'third_party/nix/src/nix-store') diff --git a/third_party/nix/src/nix-store/nix-store.cc b/third_party/nix/src/nix-store/nix-store.cc index 2183d053e577..9f37bfbcac99 100644 --- a/third_party/nix/src/nix-store/nix-store.cc +++ b/third_party/nix/src/nix-store/nix-store.cc @@ -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(*store, in); in >> info.registrationTime >> info.narSize >> info.ultimate; info.sigs = readStrings(in); -- cgit 1.4.1