aboutsummaryrefslogtreecommitdiff
path: root/src/nix
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2020-06-02 15:52:13 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2020-06-02 15:52:13 +0000
commit450dcf2c1b60a36f5ffeab2411805287d122bcdd (patch)
treed1fe49020e97198147483f42454da46f36e42094 /src/nix
parent6dd471ebf6b9a4996405398093ccb371b8abdf2f (diff)
Remove `HashType::Unknown`
Instead, `Hash` uses `std::optional<HashType>`. In the future, we may also make `Hash` itself require a known hash type, encoraging people to use `std::optional<Hash>` instead.
Diffstat (limited to 'src/nix')
-rw-r--r--src/nix/hash.cc4
-rw-r--r--src/nix/verify.cc4
2 files changed, 3 insertions, 5 deletions
diff --git a/src/nix/hash.cc b/src/nix/hash.cc
index 3362ffd0d..4980cd198 100644
--- a/src/nix/hash.cc
+++ b/src/nix/hash.cc
@@ -79,7 +79,7 @@ static RegisterCommand r2("hash-path", [](){ return make_ref<CmdHash>(FileIngest
struct CmdToBase : Command
{
Base base;
- HashType ht = HashType::Unknown;
+ HashType ht;
std::vector<std::string> args;
CmdToBase(Base base) : base(base)
@@ -132,8 +132,6 @@ static int compatNixHash(int argc, char * * argv)
else if (*arg == "--type") {
string s = getArg(*arg, arg, end);
ht = parseHashType(s);
- if (ht == HashType::Unknown)
- throw UsageError(format("unknown hash type '%1%'") % s);
}
else if (*arg == "--to-base16") op = opTo16;
else if (*arg == "--to-base32") op = opTo32;
diff --git a/src/nix/verify.cc b/src/nix/verify.cc
index 0c3478ff5..fa05e7353 100644
--- a/src/nix/verify.cc
+++ b/src/nix/verify.cc
@@ -88,9 +88,9 @@ struct CmdVerify : StorePathsCommand
std::unique_ptr<AbstractHashSink> hashSink;
if (info->ca == "")
- hashSink = std::make_unique<HashSink>(info->narHash.type);
+ hashSink = std::make_unique<HashSink>(*info->narHash.type);
else
- hashSink = std::make_unique<HashModuloSink>(info->narHash.type, storePathToHash(store->printStorePath(info->path)));
+ hashSink = std::make_unique<HashModuloSink>(*info->narHash.type, storePathToHash(store->printStorePath(info->path)));
store->narFromPath(info->path, *hashSink);