From 149fe52517653a3a5c2ef5f2be2ab09415eedba4 Mon Sep 17 00:00:00 2001 From: Oliver Reiche Date: Fri, 7 Oct 2022 16:26:51 +0200 Subject: Fix upload of known source trees When a tree is taken from a git root, it is not necessarily known on the remote site. So, as any missing artifact it has to be uploaded, recursively uploading the parts to keep the tree invariant. The function RetrieveToCas was doing the correct recursiv pattern, however inspecting trees incorrectly using the function ReadTreeInfos; the latter function, however, was obtaining all the leafs of the tree as is needed for a compatible action-input description. Add and use a function that reads the direct contents of a tree. --- .../execution_api/local/local_storage.cpp | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'src/buildtool/execution_api/local/local_storage.cpp') diff --git a/src/buildtool/execution_api/local/local_storage.cpp b/src/buildtool/execution_api/local/local_storage.cpp index b8e8401c..2734577b 100644 --- a/src/buildtool/execution_api/local/local_storage.cpp +++ b/src/buildtool/execution_api/local/local_storage.cpp @@ -108,6 +108,43 @@ auto LocalStorage::ReadTreeInfos( return std::nullopt; } +auto LocalStorage::ReadTreeInfosDirect( + bazel_re::Digest const& tree_digest, + std::filesystem::path const& parent) const noexcept + -> std::optional, + std::vector>> { + std::vector paths{}; + std::vector infos{}; + + auto store_info = [&paths, &infos](auto path, auto info) { + paths.emplace_back(path); + infos.emplace_back(info); + return true; + }; + + if (Compatibility::IsCompatible()) { + 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 LocalStorage::ReadObjectInfosRecursively( BazelMsgFactory::InfoStoreFunc const& store_info, -- cgit v1.2.3