1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-03 06:11:46 +02:00

HashType: Rename to HashAlgorithm

To be consistent with CLI, nix API
and many other references.

As part of this, we also converted it to a scoped enum.

https://github.com/NixOS/nix/issues/8876
This commit is contained in:
Peter Kolloch 2023-11-28 14:20:27 +01:00
parent 0c2d5f7673
commit 5334c9c792
64 changed files with 450 additions and 450 deletions

View file

@ -193,7 +193,7 @@ static void opAddFixed(Strings opFlags, Strings opArgs)
if (opArgs.empty())
throw UsageError("first argument must be hash algorithm");
HashType hashAlgo = parseHashType(opArgs.front());
HashAlgorithm hashAlgo = parseHashAlgo(opArgs.front());
opArgs.pop_front();
for (auto & i : opArgs)
@ -214,7 +214,7 @@ static void opPrintFixedPath(Strings opFlags, Strings opArgs)
throw UsageError("'--print-fixed-path' requires three arguments");
Strings::iterator i = opArgs.begin();
HashType hashAlgo = parseHashType(*i++);
HashAlgorithm hashAlgo = parseHashAlgo(*i++);
std::string hash = *i++;
std::string name = *i++;
@ -405,7 +405,7 @@ static void opQuery(Strings opFlags, Strings opArgs)
for (auto & j : maybeUseOutputs(store->followLinksToStorePath(i), useOutput, forceRealise)) {
auto info = store->queryPathInfo(j);
if (query == qHash) {
assert(info->narHash.type == htSHA256);
assert(info->narHash.algo == HashAlgorithm::SHA256);
cout << fmt("%s\n", info->narHash.to_string(HashFormat::Base32, true));
} else if (query == qSize)
cout << fmt("%d\n", info->narSize);
@ -541,7 +541,7 @@ static void registerValidity(bool reregister, bool hashGiven, bool canonicalise)
if (canonicalise)
canonicalisePathMetaData(store->printStorePath(info->path), {});
if (!hashGiven) {
HashResult hash = hashPath(htSHA256, store->printStorePath(info->path));
HashResult hash = hashPath(HashAlgorithm::SHA256, store->printStorePath(info->path));
info->narHash = hash.first;
info->narSize = hash.second;
}
@ -763,7 +763,7 @@ static void opVerifyPath(Strings opFlags, Strings opArgs)
auto path = store->followLinksToStorePath(i);
printMsg(lvlTalkative, "checking path '%s'...", store->printStorePath(path));
auto info = store->queryPathInfo(path);
HashSink sink(info->narHash.type);
HashSink sink(info->narHash.algo);
store->narFromPath(path, sink);
auto current = sink.finish();
if (current.first != info->narHash) {
@ -979,7 +979,7 @@ static void opServe(Strings opFlags, Strings opArgs)
auto deriver = readString(in);
ValidPathInfo info {
store->parseStorePath(path),
Hash::parseAny(readString(in), htSHA256),
Hash::parseAny(readString(in), HashAlgorithm::SHA256),
};
if (deriver != "")
info.deriver = store->parseStorePath(deriver);