diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2025-02-25 11:46:51 +0100 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2025-02-27 09:03:30 +0100 |
commit | b3c6d3572784575811ff130d859e92b799e77bb3 (patch) | |
tree | dc37456d28fa9e464bdd50eb3218a6917c73e4be /src/buildtool/execution_api/remote/bazel/bazel_api.cpp | |
parent | 9a987188a38cc18f6a485bd5def16aded10fe1f6 (diff) | |
download | justbuild-b3c6d3572784575811ff130d859e92b799e77bb3.tar.gz |
ArtifactBlob: Check access to the content
Diffstat (limited to 'src/buildtool/execution_api/remote/bazel/bazel_api.cpp')
-rw-r--r-- | src/buildtool/execution_api/remote/bazel/bazel_api.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
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</*kSetEpochTime=*/true, - /*kSetWritable=*/true>( - *blobs[pos].ReadContent(), output_paths[gpos], type)) { + + bool written = false; + if (auto const content = blobs[pos].ReadContent()) { + written = FileSystemManager::WriteFileAs</*kSetEpochTime=*/true, + /*kSetWritable=*/true>( + *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<std::string> { 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); + } } } }); |