diff options
Diffstat (limited to 'src/buildtool/execution_api/remote')
3 files changed, 47 insertions, 2 deletions
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_api.cpp b/src/buildtool/execution_api/remote/bazel/bazel_api.cpp index d1de9a68..34cb129e 100644 --- a/src/buildtool/execution_api/remote/bazel/bazel_api.cpp +++ b/src/buildtool/execution_api/remote/bazel/bazel_api.cpp @@ -170,8 +170,8 @@ auto BazelApi::CreateAction( std::vector<bazel_re::Digest> blob_digests{}; for (auto const& info : missing_artifacts_info) { if (IsTreeObject(info.type)) { - auto const infos = - network_->ReadTreeInfos(info.digest, std::filesystem::path{}); + auto const infos = network_->ReadTreeInfosDirect( + info.digest, std::filesystem::path{}); if (not infos or not RetrieveToCas(infos->second, api)) { return false; } diff --git a/src/buildtool/execution_api/remote/bazel/bazel_network.cpp b/src/buildtool/execution_api/remote/bazel/bazel_network.cpp index e4205d25..4fb9398b 100644 --- a/src/buildtool/execution_api/remote/bazel/bazel_network.cpp +++ b/src/buildtool/execution_api/remote/bazel/bazel_network.cpp @@ -279,6 +279,45 @@ auto BazelNetwork::ReadTreeInfos(bazel_re::Digest const& tree_digest, return std::nullopt; } +auto BazelNetwork::ReadTreeInfosDirect( + bazel_re::Digest const& tree_digest, + std::filesystem::path const& parent) const noexcept + -> std::optional<std::pair<std::vector<std::filesystem::path>, + std::vector<Artifact::ObjectInfo>>> { + std::vector<std::filesystem::path> paths{}; + std::vector<Artifact::ObjectInfo> infos{}; + + auto store_info = [&paths, &infos](auto path, auto info) { + paths.emplace_back(path); + infos.emplace_back(info); + return true; + }; + + if (Compatibility::IsCompatible()) { + // read from CAS + if (auto dir = ReadDirectory(this, tree_digest)) { + if (not BazelMsgFactory::ReadObjectInfosFromDirectory( + *dir, [&store_info, &parent](auto path, auto info) { + return store_info(parent / path, info); + })) { + return std::nullopt; + } + } + } + else { + if (auto entries = ReadGitTree(this, tree_digest)) { + if (not BazelMsgFactory::ReadObjectInfosFromGitTree( + *entries, [&store_info, &parent](auto path, auto info) { + return store_info(parent / path, info); + })) { + return std::nullopt; + } + } + } + + return std::make_pair(std::move(paths), std::move(infos)); +} + // NOLINTNEXTLINE(misc-no-recursion) auto BazelNetwork::ReadObjectInfosRecursively( std::optional<DirectoryMap> const& dir_map, diff --git a/src/buildtool/execution_api/remote/bazel/bazel_network.hpp b/src/buildtool/execution_api/remote/bazel/bazel_network.hpp index a323e00b..7b0d69ae 100644 --- a/src/buildtool/execution_api/remote/bazel/bazel_network.hpp +++ b/src/buildtool/execution_api/remote/bazel/bazel_network.hpp @@ -85,6 +85,12 @@ class BazelNetwork { -> std::optional<std::pair<std::vector<std::filesystem::path>, std::vector<Artifact::ObjectInfo>>>; + [[nodiscard]] auto ReadTreeInfosDirect( + bazel_re::Digest const& tree_digest, + std::filesystem::path const& parent) const noexcept + -> std::optional<std::pair<std::vector<std::filesystem::path>, + std::vector<Artifact::ObjectInfo>>>; + [[nodiscard]] auto DumpToStream( Artifact::ObjectInfo const& info, gsl::not_null<FILE*> const& stream) const noexcept -> bool; |