diff options
author | Jade Lovelace <lix@jade.fyi> | 2024-08-01 13:42:02 -0700 |
---|---|---|
committer | Jade Lovelace <lix@jade.fyi> | 2024-08-08 14:53:17 -0700 |
commit | 370ac940dd7816ad4052fafa4e0f8d17784fa16b (patch) | |
tree | 8b44ebb7e8f4e218c1b4e57edfc6aaac212b90fa /src/libfetchers/fetchers.cc | |
parent | f3ef0899c744ff5256414c8539c75e798a058ee0 (diff) |
refactor: make HashType and Base enum classes for type safety
Change-Id: I9fbd55a9d50464a56fe11cb42a06a206914150d8
Diffstat (limited to 'src/libfetchers/fetchers.cc')
-rw-r--r-- | src/libfetchers/fetchers.cc | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/libfetchers/fetchers.cc b/src/libfetchers/fetchers.cc index e09513d8f..c441ffb12 100644 --- a/src/libfetchers/fetchers.cc +++ b/src/libfetchers/fetchers.cc @@ -153,12 +153,12 @@ std::pair<Tree, Input> Input::fetch(ref<Store> store) const }; auto narHash = store->queryPathInfo(tree.storePath)->narHash; - input.attrs.insert_or_assign("narHash", narHash.to_string(SRI, true)); + input.attrs.insert_or_assign("narHash", narHash.to_string(Base::SRI, true)); if (auto prevNarHash = getNarHash()) { if (narHash != *prevNarHash) throw Error((unsigned int) 102, "NAR hash mismatch in input '%s' (%s), expected '%s', got '%s'", - to_string(), tree.actualPath, prevNarHash->to_string(SRI, true), narHash.to_string(SRI, true)); + to_string(), tree.actualPath, prevNarHash->to_string(Base::SRI, true), narHash.to_string(Base::SRI, true)); } if (auto prevLastModified = getLastModified()) { @@ -240,8 +240,8 @@ std::string Input::getType() const std::optional<Hash> Input::getNarHash() const { if (auto s = maybeGetStrAttr(attrs, "narHash")) { - auto hash = s->empty() ? Hash(htSHA256) : Hash::parseSRI(*s); - if (hash.type != htSHA256) + auto hash = s->empty() ? Hash(HashType::SHA256) : Hash::parseSRI(*s); + if (hash.type != HashType::SHA256) throw UsageError("narHash must use SHA-256"); return hash; } @@ -264,7 +264,7 @@ std::optional<Hash> Input::getRev() const hash = Hash::parseAnyPrefixed(*s); } catch (BadHash &e) { // Default to sha1 for backwards compatibility with existing flakes - hash = Hash::parseAny(*s, htSHA1); + hash = Hash::parseAny(*s, HashType::SHA1); } } |