summaryrefslogtreecommitdiff
path: root/src/buildtool/execution_api/local/local_api.hpp
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2024-05-27 14:57:15 +0200
committerMaksim Denisov <denisov.maksim@huawei.com>2024-05-28 16:19:19 +0200
commitfd8ad0f561dd253bf7399ce9a4594242e918ca25 (patch)
treed72aa981cafc03d0f1aded827cb621fabe541fff /src/buildtool/execution_api/local/local_api.hpp
parent9bdd30f307b83a3901250a51780f308f5c4a0065 (diff)
downloadjustbuild-fd8ad0f561dd253bf7399ce9a4594242e918ca25.tar.gz
Use ArtifactBlobContainer in IExecutionApi
...instead of BazelBlobContainer to not bring bazel_re::Digest to IExecutionApi.
Diffstat (limited to 'src/buildtool/execution_api/local/local_api.hpp')
-rw-r--r--src/buildtool/execution_api/local/local_api.hpp25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/buildtool/execution_api/local/local_api.hpp b/src/buildtool/execution_api/local/local_api.hpp
index 978d3968..153f9971 100644
--- a/src/buildtool/execution_api/local/local_api.hpp
+++ b/src/buildtool/execution_api/local/local_api.hpp
@@ -191,7 +191,7 @@ class LocalApi final : public IExecutionApi {
// Collect blobs of missing artifacts from local CAS. Trees are
// processed recursively before any blob is uploaded.
- BazelBlobContainer container{};
+ ArtifactBlobContainer container{};
for (auto const& dgst : missing_artifacts_info->digests) {
auto const& info = missing_artifacts_info->back_map[dgst];
// Recursively process trees.
@@ -222,18 +222,16 @@ class LocalApi final : public IExecutionApi {
// Regenerate digest since object infos read by
// storage_->ReadTreeInfos() will contain 0 as size.
- ArtifactDigest digest;
- if (IsTreeObject(info.type)) {
- digest = ArtifactDigest::Create<ObjectType::Tree>(*content);
- }
- else {
- digest = ArtifactDigest::Create<ObjectType::File>(*content);
- }
+ ArtifactDigest digest =
+ IsTreeObject(info.type)
+ ? ArtifactDigest::Create<ObjectType::Tree>(*content)
+ : ArtifactDigest::Create<ObjectType::File>(*content);
// Collect blob.
try {
- container.Emplace(
- BazelBlob{digest, *content, IsExecutableObject(info.type)});
+ container.Emplace(ArtifactBlob{std::move(digest),
+ *content,
+ IsExecutableObject(info.type)});
} catch (std::exception const& ex) {
Logger::Log(
LogLevel::Error, "failed to emplace blob: ", ex.what());
@@ -242,7 +240,7 @@ class LocalApi final : public IExecutionApi {
}
// Upload blobs to remote CAS.
- return api->Upload(container, /*skip_find_missing=*/true);
+ return api->Upload(std::move(container), /*skip_find_missing=*/true);
}
[[nodiscard]] auto RetrieveToMemory(
@@ -267,11 +265,12 @@ class LocalApi final : public IExecutionApi {
return content;
}
- [[nodiscard]] auto Upload(BazelBlobContainer const& blobs,
+ [[nodiscard]] auto Upload(ArtifactBlobContainer&& blobs,
bool /*skip_find_missing*/) noexcept
-> bool final {
for (auto const& blob : blobs.Blobs()) {
- auto const is_tree = NativeSupport::IsTree(blob.digest.hash());
+ auto const is_tree = NativeSupport::IsTree(
+ static_cast<bazel_re::Digest>(blob.digest).hash());
auto cas_digest =
is_tree ? storage_->CAS().StoreTree(blob.data)
: storage_->CAS().StoreBlob(blob.data, blob.is_exec);