From f94b4663dc61a2987912faa3f1cd71378db0ad33 Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Mon, 8 Jul 2024 15:07:36 +0200 Subject: Pass HashFunction to BazelNetwork --- .../execution_api/remote/bazel/bazel_response.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/buildtool/execution_api/remote/bazel/bazel_response.cpp') diff --git a/src/buildtool/execution_api/remote/bazel/bazel_response.cpp b/src/buildtool/execution_api/remote/bazel/bazel_response.cpp index 0cb860a3..7db88a08 100644 --- a/src/buildtool/execution_api/remote/bazel/bazel_response.cpp +++ b/src/buildtool/execution_api/remote/bazel/bazel_response.cpp @@ -28,11 +28,11 @@ namespace { -auto ProcessDirectoryMessage(bazel_re::Directory const& dir) noexcept +auto ProcessDirectoryMessage(HashFunction hash_function, + bazel_re::Directory const& dir) noexcept -> std::optional { auto data = dir.SerializeAsString(); - auto digest = ArtifactDigest::Create( - HashFunction::Instance(), data); + auto digest = ArtifactDigest::Create(hash_function, data); return BazelBlob{std::move(digest), std::move(data), /*is_exec=*/false}; } @@ -102,7 +102,7 @@ auto BazelResponse::Populate() noexcept -> bool { link.path(), Artifact::ObjectInfo{ .digest = ArtifactDigest::Create( - HashFunction::Instance(), link.target()), + network_->GetHashFunction(), link.target()), .type = ObjectType::Symlink}); } catch (...) { return false; @@ -114,7 +114,7 @@ auto BazelResponse::Populate() noexcept -> bool { link.path(), Artifact::ObjectInfo{ .digest = ArtifactDigest::Create( - HashFunction::Instance(), link.target()), + network_->GetHashFunction(), link.target()), .type = ObjectType::Symlink}); dir_symlinks.emplace(link.path()); // add it to set } catch (...) { @@ -129,7 +129,7 @@ auto BazelResponse::Populate() noexcept -> bool { link.path(), Artifact::ObjectInfo{ .digest = ArtifactDigest::Create( - HashFunction::Instance(), link.target()), + network_->GetHashFunction(), link.target()), .type = ObjectType::Symlink}); } catch (...) { return false; @@ -141,7 +141,7 @@ auto BazelResponse::Populate() noexcept -> bool { link.path(), Artifact::ObjectInfo{ .digest = ArtifactDigest::Create( - HashFunction::Instance(), link.target()), + network_->GetHashFunction(), link.target()), .type = ObjectType::Symlink}); } catch (...) { return false; @@ -215,7 +215,8 @@ auto BazelResponse::UploadTreeMessageDirectories( bazel_re::Tree const& tree) const -> std::optional { BazelBlobContainer dir_blobs{}; - auto rootdir_blob = ProcessDirectoryMessage(tree.root()); + auto rootdir_blob = + ProcessDirectoryMessage(network_->GetHashFunction(), tree.root()); if (not rootdir_blob) { return std::nullopt; } @@ -234,7 +235,8 @@ auto BazelResponse::UploadTreeMessageDirectories( } for (auto const& subdir : tree.children()) { - auto subdir_blob = ProcessDirectoryMessage(subdir); + auto subdir_blob = + ProcessDirectoryMessage(network_->GetHashFunction(), subdir); if (not subdir_blob) { return std::nullopt; } -- cgit v1.2.3