diff options
Diffstat (limited to 'src')
7 files changed, 45 insertions, 17 deletions
diff --git a/src/buildtool/execution_api/local/local_action.cpp b/src/buildtool/execution_api/local/local_action.cpp index af0f2476..3e9311d3 100644 --- a/src/buildtool/execution_api/local/local_action.cpp +++ b/src/buildtool/execution_api/local/local_action.cpp @@ -155,7 +155,7 @@ auto LocalAction::StageInputFiles( return false; } - auto infos = storage_->ReadTreeInfos(root_digest_, exec_path); + auto infos = storage_->RecursivelyReadTreeLeafs(root_digest_, exec_path); if (not infos) { return false; } diff --git a/src/buildtool/execution_api/local/local_api.hpp b/src/buildtool/execution_api/local/local_api.hpp index dd3bc4a0..48d06640 100644 --- a/src/buildtool/execution_api/local/local_api.hpp +++ b/src/buildtool/execution_api/local/local_api.hpp @@ -48,8 +48,8 @@ class LocalApi final : public IExecutionApi { auto const& info = artifacts_info[i]; if (IsTreeObject(info.type)) { // read object infos from sub tree and call retrieve recursively - auto const infos = - storage_->ReadTreeInfos(info.digest, output_paths[i]); + auto const infos = storage_->RecursivelyReadTreeLeafs( + info.digest, output_paths[i]); if (not infos or not RetrieveToPaths(infos->second, infos->first)) { return false; @@ -134,7 +134,7 @@ class LocalApi final : public IExecutionApi { for (auto const& info : missing_artifacts_info) { // Recursively process trees. if (IsTreeObject(info.type)) { - auto const& infos = storage_->ReadTreeInfosDirect( + auto const& infos = storage_->ReadDirectTreeEntries( info.digest, std::filesystem::path{}); if (not infos or not RetrieveToCas(infos->second, api)) { return false; diff --git a/src/buildtool/execution_api/local/local_storage.cpp b/src/buildtool/execution_api/local/local_storage.cpp index 2734577b..f784fbf8 100644 --- a/src/buildtool/execution_api/local/local_storage.cpp +++ b/src/buildtool/execution_api/local/local_storage.cpp @@ -88,7 +88,7 @@ namespace { } // namespace -auto LocalStorage::ReadTreeInfos( +auto LocalStorage::RecursivelyReadTreeLeafs( bazel_re::Digest const& tree_digest, std::filesystem::path const& parent) const noexcept -> std::optional<std::pair<std::vector<std::filesystem::path>, @@ -108,7 +108,7 @@ auto LocalStorage::ReadTreeInfos( return std::nullopt; } -auto LocalStorage::ReadTreeInfosDirect( +auto LocalStorage::ReadDirectTreeEntries( bazel_re::Digest const& tree_digest, std::filesystem::path const& parent) const noexcept -> std::optional<std::pair<std::vector<std::filesystem::path>, diff --git a/src/buildtool/execution_api/local/local_storage.hpp b/src/buildtool/execution_api/local/local_storage.hpp index 888f39c8..6c5700be 100644 --- a/src/buildtool/execution_api/local/local_storage.hpp +++ b/src/buildtool/execution_api/local/local_storage.hpp @@ -69,13 +69,26 @@ class LocalStorage { return ac_.CachedResult(action_id); } - [[nodiscard]] auto ReadTreeInfos( + /// \brief Traverses a tree recursively and retrieves object infos of all + /// found blobs (leafs). Tree objects are not added to the result list, but + /// converted to a path name. + /// \param tree_digest Digest of the tree. + /// \param parent Local parent path. + /// \returns Pair of vectors, first containing filesystem paths, second + /// containing object infos. + [[nodiscard]] auto RecursivelyReadTreeLeafs( 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 ReadTreeInfosDirect( + /// \brief Reads the flat content of a tree and returns object infos of all + /// its direct entries (trees and blobs). + /// \param tree_digest Digest of the tree. + /// \param parent Local parent path. + /// \returns Pair of vectors, first containing filesystem paths, second + /// containing object infos. + [[nodiscard]] auto ReadDirectTreeEntries( bazel_re::Digest const& tree_digest, std::filesystem::path const& parent) const noexcept -> std::optional<std::pair<std::vector<std::filesystem::path>, diff --git a/src/buildtool/execution_api/remote/bazel/bazel_api.cpp b/src/buildtool/execution_api/remote/bazel/bazel_api.cpp index 34cb129e..99d77a5e 100644 --- a/src/buildtool/execution_api/remote/bazel/bazel_api.cpp +++ b/src/buildtool/execution_api/remote/bazel/bazel_api.cpp @@ -68,8 +68,8 @@ auto BazelApi::CreateAction( auto const& info = artifacts_info[i]; if (IsTreeObject(info.type)) { // read object infos from sub tree and call retrieve recursively - auto const infos = - network_->ReadTreeInfos(info.digest, output_paths[i]); + auto const infos = network_->RecursivelyReadTreeLeafs( + info.digest, output_paths[i]); if (not infos or not RetrieveToPaths(infos->second, infos->first)) { return false; } @@ -170,7 +170,7 @@ 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_->ReadTreeInfosDirect( + auto const infos = network_->ReadDirectTreeEntries( 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 4fb9398b..681811cf 100644 --- a/src/buildtool/execution_api/remote/bazel/bazel_network.cpp +++ b/src/buildtool/execution_api/remote/bazel/bazel_network.cpp @@ -237,9 +237,10 @@ auto BazelNetwork::GetCachedActionResult( instance_name_, action, false, false, output_files); } -auto BazelNetwork::ReadTreeInfos(bazel_re::Digest const& tree_digest, - std::filesystem::path const& parent, - bool request_remote_tree) const noexcept +auto BazelNetwork::RecursivelyReadTreeLeafs( + bazel_re::Digest const& tree_digest, + std::filesystem::path const& parent, + bool request_remote_tree) const noexcept -> std::optional<std::pair<std::vector<std::filesystem::path>, std::vector<Artifact::ObjectInfo>>> { std::optional<DirectoryMap> dir_map{std::nullopt}; @@ -279,7 +280,7 @@ auto BazelNetwork::ReadTreeInfos(bazel_re::Digest const& tree_digest, return std::nullopt; } -auto BazelNetwork::ReadTreeInfosDirect( +auto BazelNetwork::ReadDirectTreeEntries( bazel_re::Digest const& tree_digest, std::filesystem::path const& parent) const noexcept -> std::optional<std::pair<std::vector<std::filesystem::path>, diff --git a/src/buildtool/execution_api/remote/bazel/bazel_network.hpp b/src/buildtool/execution_api/remote/bazel/bazel_network.hpp index 7b0d69ae..2143b47a 100644 --- a/src/buildtool/execution_api/remote/bazel/bazel_network.hpp +++ b/src/buildtool/execution_api/remote/bazel/bazel_network.hpp @@ -78,14 +78,28 @@ class BazelNetwork { std::vector<std::string> const& output_files) const noexcept -> std::optional<bazel_re::ActionResult>; - [[nodiscard]] auto ReadTreeInfos( + /// \brief Traverses a tree recursively and retrieves object infos of all + /// found blobs. Tree objects are not added to the result list, but + /// converted to a path name. + /// \param tree_digest Digest of the tree. + /// \param parent Local parent path. + /// \param request_remote_tree Query full tree from remote CAS. + /// \returns Pair of vectors, first containing filesystem paths, second + /// containing object infos. + [[nodiscard]] auto RecursivelyReadTreeLeafs( bazel_re::Digest const& tree_digest, std::filesystem::path const& parent, bool request_remote_tree = false) const noexcept -> std::optional<std::pair<std::vector<std::filesystem::path>, std::vector<Artifact::ObjectInfo>>>; - [[nodiscard]] auto ReadTreeInfosDirect( + /// \brief Reads the flat content of a tree and returns object infos of all + /// its direct entries (trees and blobs). + /// \param tree_digest Digest of the tree. + /// \param parent Local parent path. + /// \returns Pair of vectors, first containing filesystem paths, second + /// containing object infos. + [[nodiscard]] auto ReadDirectTreeEntries( bazel_re::Digest const& tree_digest, std::filesystem::path const& parent) const noexcept -> std::optional<std::pair<std::vector<std::filesystem::path>, |