From 51f8b186803292f111011d04d5291deb374dc34c Mon Sep 17 00:00:00 2001 From: Oliver Reiche Date: Thu, 6 Oct 2022 12:18:25 +0200 Subject: LocalTreeMap: Prevent tree objects from being stored ... to align with the original idea of caching a flat list of blob objects, without the need to recursively traverse any trees. Consequently, we cannot create any map entry in places where we do not have all sub-tree entries at hand (e.g., LocalAPI, BazelAPI, BazelResponse). --- src/buildtool/execution_api/local/local_action.cpp | 40 +++------------------- 1 file changed, 5 insertions(+), 35 deletions(-) (limited to 'src/buildtool/execution_api/local/local_action.cpp') diff --git a/src/buildtool/execution_api/local/local_action.cpp b/src/buildtool/execution_api/local/local_action.cpp index 0c15e788..af0f2476 100644 --- a/src/buildtool/execution_api/local/local_action.cpp +++ b/src/buildtool/execution_api/local/local_action.cpp @@ -248,20 +248,9 @@ auto LocalAction::CollectOutputDir(std::filesystem::path const& exec_path, [this](auto path, auto is_exec) { return storage_->StoreBlob(path, is_exec); }, - [this](auto bytes, auto dir) -> std::optional { - auto digest = storage_->StoreBlob(bytes); - if (digest and not tree_map_->HasTree(*digest)) { - auto tree = tree_map_->CreateTree(); - if (not BazelMsgFactory::ReadObjectInfosFromDirectory( - dir, - [&tree](auto path, auto info) { - return tree.AddInfo(path, info); - }) or - not tree_map_->AddTree(*digest, std::move(tree))) { - return std::nullopt; - } - } - return digest; + [this](auto bytes, + auto /*dir*/) -> std::optional { + return storage_->StoreBlob(bytes); }); } else { @@ -271,27 +260,8 @@ auto LocalAction::CollectOutputDir(std::filesystem::path const& exec_path, return storage_->StoreBlob(path, is_exec); }, [this](auto bytes, - auto entries) -> std::optional { - auto digest = storage_->StoreTree(bytes); - if (digest and not tree_map_->HasTree(*digest)) { - auto tree = tree_map_->CreateTree(); - for (auto const& [raw_id, es] : entries) { - auto id = ToHexString(raw_id); - for (auto const& entry : es) { - auto info = Artifact::ObjectInfo{ - ArtifactDigest{ - id, 0, entry.type == ObjectType::Tree}, - entry.type}; - if (not tree.AddInfo(entry.name, info)) { - return std::nullopt; - } - } - } - if (not tree_map_->AddTree(*digest, std::move(tree))) { - return std::nullopt; - } - } - return digest; + auto /*entries*/) -> std::optional { + return storage_->StoreTree(bytes); }); } if (digest) { -- cgit v1.2.3