From c30cb3221989b60cee96287a1cb9d9e87f9ba464 Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Wed, 29 Jan 2025 14:34:36 +0100 Subject: BazelNetwork: Use ArtifactBlobs in UploadBlobs --- .../execution_api/remote/bazel/bazel_response.cpp | 28 ++++++++++------------ 1 file changed, 13 insertions(+), 15 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 81f8310d..e4bc9248 100644 --- a/src/buildtool/execution_api/remote/bazel/bazel_response.cpp +++ b/src/buildtool/execution_api/remote/bazel/bazel_response.cpp @@ -26,11 +26,10 @@ #include "src/buildtool/common/artifact.hpp" #include "src/buildtool/common/artifact_digest.hpp" #include "src/buildtool/common/artifact_digest_factory.hpp" -#include "src/buildtool/common/bazel_digest_factory.hpp" #include "src/buildtool/common/protocol_traits.hpp" #include "src/buildtool/crypto/hash_function.hpp" -#include "src/buildtool/execution_api/bazel_msg/bazel_blob_container.hpp" #include "src/buildtool/execution_api/bazel_msg/bazel_msg_factory.hpp" +#include "src/buildtool/execution_api/common/artifact_blob_container.hpp" #include "src/buildtool/execution_api/common/common_api.hpp" #include "src/buildtool/execution_api/common/content_blob_container.hpp" #include "src/buildtool/execution_api/remote/bazel/bazel_network_reader.hpp" @@ -44,7 +43,7 @@ namespace { auto ProcessDirectoryMessage(HashFunction hash_function, bazel_re::Directory const& dir) noexcept - -> expected { + -> expected { // in compatible mode: check validity of all symlinks for (auto const& link : dir.symlinks()) { if (not PathIsNonUpwards(link.target())) { @@ -53,11 +52,11 @@ auto ProcessDirectoryMessage(HashFunction hash_function, } } auto data = dir.SerializeAsString(); - auto digest = - BazelDigestFactory::HashDataAs(hash_function, data); - return BazelBlob{std::move(digest), - std::move(data), - /*is_exec=*/false}; + auto digest = ArtifactDigestFactory::HashDataAs( + hash_function, data); + return ArtifactBlob{std::move(digest), + std::move(data), + /*is_exec=*/false}; } } // namespace @@ -282,11 +281,12 @@ auto BazelResponse::Populate() noexcept -> std::optional { auto BazelResponse::UploadTreeMessageDirectories( bazel_re::Tree const& tree) const -> expected { auto const upload_callback = - [&network = *network_](std::unordered_set&& blobs) -> bool { + [&network = + *network_](std::unordered_set&& blobs) -> bool { return network.UploadBlobs(std::move(blobs)); }; auto const hash_function = network_->GetHashFunction(); - std::unordered_set dir_blobs{}; + std::unordered_set dir_blobs{}; auto rootdir_blob = ProcessDirectoryMessage(hash_function, tree.root()); if (not rootdir_blob) { @@ -294,7 +294,7 @@ auto BazelResponse::UploadTreeMessageDirectories( } auto const root_digest = rootdir_blob->digest; // store or upload rootdir blob, taking maximum transfer size into account - if (not UpdateContainerAndUpload( + if (not UpdateContainerAndUpload( &dir_blobs, *std::move(rootdir_blob), /*exception_is_fatal=*/false, @@ -310,7 +310,7 @@ auto BazelResponse::UploadTreeMessageDirectories( return unexpected{std::move(blob).error()}; } auto const blob_digest = blob->digest; - if (not UpdateContainerAndUpload( + if (not UpdateContainerAndUpload( &dir_blobs, *std::move(blob), /*exception_is_fatal=*/false, @@ -327,7 +327,5 @@ auto BazelResponse::UploadTreeMessageDirectories( fmt::format("failed to upload blobs for Tree with root digest {}", root_digest.hash())}; } - return ArtifactDigestFactory::FromBazel(hash_function.GetType(), - root_digest) - .value(); // must succeed all the time + return root_digest; } -- cgit v1.2.3