diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2021-10-01 17:12:54 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2021-10-01 17:12:54 +0000 |
commit | 13b6b645897fd2edaa0f09fa48d6fe8dd6287b55 (patch) | |
tree | 0c6fc18fa246115402c9fd0030029d9a4ebde82f /src/libstore/content-address.cc | |
parent | f4f3203aa7c2fc9225a8ae220db25593066fb397 (diff) | |
parent | 4f496150eb4e0012914c11f0a3ff4df2412b1d09 (diff) |
Merge remote-tracking branch 'upstream/master' into path-info
Diffstat (limited to 'src/libstore/content-address.cc')
-rw-r--r-- | src/libstore/content-address.cc | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/libstore/content-address.cc b/src/libstore/content-address.cc index d68c60f4f..cb73f6eb3 100644 --- a/src/libstore/content-address.cc +++ b/src/libstore/content-address.cc @@ -31,11 +31,11 @@ std::string makeFixedOutputCA(FileIngestionMethod method, const Hash & hash) std::string renderContentAddress(ContentAddress ca) { return std::visit(overloaded { - [](TextHash th) { + [](TextHash & th) { return "text:" + th.hash.to_string(Base32, true); }, - [](FixedOutputHash fsh) { + [](FixedOutputHash & fsh) { return "fixed:" + makeFileIngestionPrefix(fsh.method) + fsh.hash.to_string(Base32, true); @@ -46,10 +46,10 @@ std::string renderContentAddress(ContentAddress ca) std::string renderContentAddressMethod(ContentAddressMethod cam) { return std::visit(overloaded { - [](TextHashMethod &th) { + [](TextHashMethod & th) { return std::string{"text:"} + printHashType(htSHA256); }, - [](FixedOutputHashMethod &fshm) { + [](FixedOutputHashMethod & fshm) { return "fixed:" + makeFileIngestionPrefix(fshm.fileIngestionMethod) + printHashType(fshm.hashType); } }, cam); @@ -107,12 +107,12 @@ ContentAddress parseContentAddress(std::string_view rawCa) { return std::visit( overloaded { - [&](TextHashMethod thm) { + [&](TextHashMethod & thm) { return ContentAddress(TextHash { .hash = Hash::parseNonSRIUnprefixed(rest, htSHA256) }); }, - [&](FixedOutputHashMethod fohMethod) { + [&](FixedOutputHashMethod & fohMethod) { return ContentAddress(FixedOutputHash { .method = fohMethod.fileIngestionMethod, .hash = Hash::parseNonSRIUnprefixed(rest, std::move(fohMethod.hashType)), @@ -140,10 +140,10 @@ std::string renderContentAddress(std::optional<ContentAddress> ca) Hash getContentAddressHash(const ContentAddress & ca) { return std::visit(overloaded { - [](TextHash th) { + [](const TextHash & th) { return th.hash; }, - [](FixedOutputHash fsh) { + [](const FixedOutputHash & fsh) { return fsh.hash; }, }, ca); @@ -151,10 +151,10 @@ Hash getContentAddressHash(const ContentAddress & ca) ContentAddressWithReferences caWithoutRefs(const ContentAddress & ca) { return std::visit(overloaded { - [&](TextHash h) -> ContentAddressWithReferences { + [&](const TextHash & h) -> ContentAddressWithReferences { return TextInfo { h, {}}; }, - [&](FixedOutputHash h) -> ContentAddressWithReferences { + [&](const FixedOutputHash & h) -> ContentAddressWithReferences { return FixedOutputInfo { h, {}}; }, }, ca); |