diff options
author | Oliver Reiche <oliver.reiche@huawei.com> | 2022-10-07 16:26:51 +0200 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2022-10-07 16:34:56 +0200 |
commit | 149fe52517653a3a5c2ef5f2be2ab09415eedba4 (patch) | |
tree | 5e223a08dee78bec91eaf4e6f94be653ca846f2a /src/buildtool/execution_api/local/local_storage.cpp | |
parent | 947a1e16e8079592773c055e86d9c4cbb8c305a8 (diff) | |
download | justbuild-149fe52517653a3a5c2ef5f2be2ab09415eedba4.tar.gz |
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.
Diffstat (limited to 'src/buildtool/execution_api/local/local_storage.cpp')
-rw-r--r-- | src/buildtool/execution_api/local/local_storage.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
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::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()) { + 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, |