From 8ab573ef1c624e2ed81b2032178c25451176d2f1 Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Fri, 14 Feb 2025 15:16:10 +0100 Subject: ApiBundle: Remove HashFunction. And ensure every user obtains HashFunction from corresponding IExecutionApi --- src/buildtool/main/archive.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/buildtool/main/archive.cpp') diff --git a/src/buildtool/main/archive.cpp b/src/buildtool/main/archive.cpp index 2d8c95db..017aaaeb 100644 --- a/src/buildtool/main/archive.cpp +++ b/src/buildtool/main/archive.cpp @@ -59,8 +59,7 @@ void archive_entry_cleanup(archive_entry* entry) { } } -auto add_to_archive(HashFunction::Type hash_type, - archive* archive, +auto add_to_archive(archive* archive, IExecutionApi const& api, const Artifact::ObjectInfo& artifact, const std::filesystem::path& location) -> bool { @@ -134,8 +133,11 @@ auto add_to_archive(HashFunction::Type hash_type, for (auto const& [hash, entries] : *git_tree) { auto hex_hash = ToHexString(hash); for (auto const& entry : entries) { - auto digest = ArtifactDigestFactory::Create( - hash_type, hex_hash, 0, IsTreeObject(entry.type)); + auto digest = + ArtifactDigestFactory::Create(api.GetHashType(), + hex_hash, + 0, + IsTreeObject(entry.type)); if (not digest) { return false; } @@ -146,8 +148,7 @@ auto add_to_archive(HashFunction::Type hash_type, } } for (auto const& [name, obj] : tree) { - if (not add_to_archive( - hash_type, archive, api, obj, location / name)) { + if (not add_to_archive(archive, api, obj, location / name)) { return false; } } @@ -160,7 +161,6 @@ auto add_to_archive(HashFunction::Type hash_type, } // namespace [[nodiscard]] auto GenerateArchive( - HashFunction::Type hash_type, IExecutionApi const& api, const Artifact::ObjectInfo& artifact, const std::optional& output_path) -> bool { @@ -204,11 +204,8 @@ auto add_to_archive(HashFunction::Type hash_type, } } - if (not add_to_archive(hash_type, - archive.get(), - api, - artifact, - std::filesystem::path{""})) { + if (not add_to_archive( + archive.get(), api, artifact, std::filesystem::path{""})) { return false; } if (output_path) { -- cgit v1.2.3