diff options
Diffstat (limited to 'src/nix')
-rw-r--r-- | src/nix/hash.cc | 6 | ||||
-rw-r--r-- | src/nix/verify.cc | 4 |
2 files changed, 4 insertions, 6 deletions
diff --git a/src/nix/hash.cc b/src/nix/hash.cc index 26bbcef1c..a36364f50 100644 --- a/src/nix/hash.cc +++ b/src/nix/hash.cc @@ -80,12 +80,12 @@ static RegisterCommand r2("hash-path", [](){ return make_ref<CmdHash>(FileIngest struct CmdToBase : Command { Base base; - HashType ht = HashType::Unknown; + std::optional<HashType> ht; std::vector<std::string> args; CmdToBase(Base base) : base(base) { - addFlag(Flag::mkHashTypeFlag("type", &ht)); + addFlag(Flag::mkHashTypeOptFlag("type", &ht)); expectArgs("strings", &args); } @@ -133,8 +133,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 d9b200591..58ffc7e4b 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); |