aboutsummaryrefslogtreecommitdiff
path: root/src/nix-store/nix-store.cc
diff options
context:
space:
mode:
authorJade Lovelace <lix@jade.fyi>2024-08-01 13:42:02 -0700
committerJade Lovelace <lix@jade.fyi>2024-08-08 14:53:17 -0700
commit370ac940dd7816ad4052fafa4e0f8d17784fa16b (patch)
tree8b44ebb7e8f4e218c1b4e57edfc6aaac212b90fa /src/nix-store/nix-store.cc
parentf3ef0899c744ff5256414c8539c75e798a058ee0 (diff)
refactor: make HashType and Base enum classes for type safety
Change-Id: I9fbd55a9d50464a56fe11cb42a06a206914150d8
Diffstat (limited to 'src/nix-store/nix-store.cc')
-rw-r--r--src/nix-store/nix-store.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc
index 8d9a49536..5762b0644 100644
--- a/src/nix-store/nix-store.cc
+++ b/src/nix-store/nix-store.cc
@@ -404,8 +404,8 @@ 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);
- cout << fmt("%s\n", info->narHash.to_string(Base32, true));
+ assert(info->narHash.type == HashType::SHA256);
+ cout << fmt("%s\n", info->narHash.to_string(Base::Base32, true));
} else if (query == qSize)
cout << fmt("%d\n", info->narSize);
}
@@ -540,7 +540,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(HashType::SHA256, store->printStorePath(info->path));
info->narHash = hash.first;
info->narSize = hash.second;
}
@@ -768,8 +768,8 @@ static void opVerifyPath(Strings opFlags, Strings opArgs)
if (current.first != info->narHash) {
printError("path '%s' was modified! expected hash '%s', got '%s'",
store->printStorePath(path),
- info->narHash.to_string(Base32, true),
- current.first.to_string(Base32, true));
+ info->narHash.to_string(Base::Base32, true),
+ current.first.to_string(Base::Base32, true));
status = 1;
}
}
@@ -970,7 +970,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), HashType::SHA256),
};
if (deriver != "")
info.deriver = store->parseStorePath(deriver);