summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2023-03-22 16:55:05 +0100
committerKlaus Aehlig <klaus.aehlig@huawei.com>2023-03-23 16:00:15 +0100
commitced48241beb02517b16984093082235a25aa6baa (patch)
treef2115e3340f46f8beabe74ba83be1e2a42691024 /src
parentcf5fe9c264d0c7199b9ca13362913916ba689c6f (diff)
downloadjustbuild-ced48241beb02517b16984093082235a25aa6baa.tar.gz
remote api: honor alternative for retrieving paths
Diffstat (limited to 'src')
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_api.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_api.cpp b/src/buildtool/execution_api/remote/bazel/bazel_api.cpp
index e98b0b5e..fcfb517d 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_api.cpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_api.cpp
@@ -73,7 +73,7 @@ auto BazelApi::CreateAction(
[[nodiscard]] auto BazelApi::RetrieveToPaths(
std::vector<Artifact::ObjectInfo> const& artifacts_info,
std::vector<std::filesystem::path> const& output_paths,
- IExecutionApi* /* alternative */) noexcept -> bool {
+ IExecutionApi* alternative) noexcept -> bool {
if (artifacts_info.size() != output_paths.size()) {
Logger::Log(LogLevel::Error,
"different number of digests and output paths.");
@@ -85,17 +85,26 @@ auto BazelApi::CreateAction(
std::vector<std::size_t> artifact_pos{};
for (std::size_t i{}; i < artifacts_info.size(); ++i) {
auto const& info = artifacts_info[i];
- if (IsTreeObject(info.type)) {
- // read object infos from sub tree and call retrieve recursively
- auto const infos = network_->RecursivelyReadTreeLeafs(
- info.digest, output_paths[i]);
- if (not infos or not RetrieveToPaths(infos->second, infos->first)) {
+ if ((alternative != nullptr) and
+ alternative->IsAvailable(info.digest)) {
+ if (not alternative->RetrieveToPaths({info}, {output_paths[i]})) {
return false;
}
}
else {
- file_digests.emplace_back(info.digest);
- artifact_pos.emplace_back(i);
+ if (IsTreeObject(info.type)) {
+ // read object infos from sub tree and call retrieve recursively
+ auto const infos = network_->RecursivelyReadTreeLeafs(
+ info.digest, output_paths[i], alternative != nullptr);
+ if (not infos or
+ not RetrieveToPaths(infos->second, infos->first)) {
+ return false;
+ }
+ }
+ else {
+ file_digests.emplace_back(info.digest);
+ artifact_pos.emplace_back(i);
+ }
}
}