From b3c6d3572784575811ff130d859e92b799e77bb3 Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Tue, 25 Feb 2025 11:46:51 +0100 Subject: ArtifactBlob: Check access to the content --- .../execution_api/remote/bazel/bazel_api.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src/buildtool/execution_api/remote/bazel/bazel_api.cpp') diff --git a/src/buildtool/execution_api/remote/bazel/bazel_api.cpp b/src/buildtool/execution_api/remote/bazel/bazel_api.cpp index ea6b71b9..eb140b3c 100644 --- a/src/buildtool/execution_api/remote/bazel/bazel_api.cpp +++ b/src/buildtool/execution_api/remote/bazel/bazel_api.cpp @@ -237,9 +237,15 @@ auto BazelApi::CreateAction( for (std::size_t pos = 0; pos < blobs.size(); ++pos) { auto gpos = artifact_pos[count + pos]; auto const& type = artifacts_info[gpos].type; - if (not FileSystemManager::WriteFileAs( - *blobs[pos].ReadContent(), output_paths[gpos], type)) { + + bool written = false; + if (auto const content = blobs[pos].ReadContent()) { + written = FileSystemManager::WriteFileAs( + *content, output_paths[gpos], type); + } + + if (not written) { Logger::Log(LogLevel::Warning, "staging to output path {} failed.", output_paths[gpos].string()); @@ -486,7 +492,9 @@ auto BazelApi::CreateAction( -> std::optional { auto reader = network_->CreateReader(); if (auto blob = reader.ReadSingleBlob(artifact_info.digest)) { - return *blob->ReadContent(); + if (auto const content = blob->ReadContent()) { + return *content; + } } return std::nullopt; } @@ -520,7 +528,9 @@ auto BazelApi::CreateAction( targets->reserve(digests.size()); for (auto blobs : reader.ReadIncrementally(&digests)) { for (auto const& blob : blobs) { - targets->emplace_back(*blob.ReadContent()); + if (auto const content = blob.ReadContent()) { + targets->emplace_back(*content); + } } } }); -- cgit v1.2.3