From 0be15127f1ecbd4010c657e908e62ed5f4b737dc Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Thu, 12 Sep 2024 11:52:55 +0200 Subject: Pass HashFunction::Type to SourceTargetMap ...that is to be used by FileRoot::ToArtifactDescription. --- src/buildtool/file_system/file_root.hpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/buildtool/file_system/file_root.hpp') diff --git a/src/buildtool/file_system/file_root.hpp b/src/buildtool/file_system/file_root.hpp index 798d8341..50065bfd 100644 --- a/src/buildtool/file_system/file_root.hpp +++ b/src/buildtool/file_system/file_root.hpp @@ -576,6 +576,7 @@ class FileRoot { // Create LOCAL or KNOWN artifact. Does not check existence for LOCAL. // `file_path` must reference a blob. [[nodiscard]] auto ToArtifactDescription( + HashFunction::Type hash_type, std::filesystem::path const& file_path, std::string const& repository) const noexcept -> std::optional { @@ -584,26 +585,26 @@ class FileRoot { std::get(root_).tree->LookupEntryByPath( file_path)) { if (entry->IsBlob()) { - if (ProtocolTraits::Instance().IsCompatible()) { + if (not ProtocolTraits::IsNative(hash_type)) { auto compatible_hash = GitHashesConverter::Instance().RegisterGitEntry( entry->Hash(), *entry->Blob(), repository); - auto digest = ArtifactDigestFactory::Create( - HashFunction::Type::PlainSHA256, - compatible_hash, - *entry->Size(), - /*is_tree=*/false); + auto digest = + ArtifactDigestFactory::Create(hash_type, + compatible_hash, + *entry->Size(), + /*is_tree=*/false); if (not digest) { return std::nullopt; } return ArtifactDescription::CreateKnown( *std::move(digest), entry->Type()); } - auto digest = ArtifactDigestFactory::Create( - HashFunction::Type::GitSHA1, - entry->Hash(), - *entry->Size(), - /*is_tree=*/false); + auto digest = + ArtifactDigestFactory::Create(hash_type, + entry->Hash(), + *entry->Size(), + /*is_tree=*/false); if (not digest) { return std::nullopt; } -- cgit v1.2.3