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/common/local_tree_map.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/buildtool/execution_api/common/local_tree_map.hpp') diff --git a/src/buildtool/execution_api/common/local_tree_map.hpp b/src/buildtool/execution_api/common/local_tree_map.hpp index 2758c339..915c7a71 100644 --- a/src/buildtool/execution_api/common/local_tree_map.hpp +++ b/src/buildtool/execution_api/common/local_tree_map.hpp @@ -40,19 +40,23 @@ class LocalTreeMap { }; public: - /// \brief Maps blob locations to object infos. + /// \brief Maps blob paths to object infos. + /// Stores a flat list of blobs, without any trees. Subtrees are represented + /// by joining the tree segments for the blob's path. class LocalTree { friend class LocalTreeMap; public: /// \brief Add a new path and info pair to the tree. /// Path must not be absolute, empty, or contain dot-segments. + /// Object MUST NOT be a tree object. /// \param path The location to add the object info. /// \param info The object info to add. /// \returns true if successfully inserted or info existed before. [[nodiscard]] auto AddInfo(std::filesystem::path const& path, Artifact::ObjectInfo const& info) noexcept -> bool { + gsl_Expects(not IsTreeObject(info.type)); auto norm_path = path.lexically_normal(); if (norm_path.is_absolute() or norm_path.empty() or *norm_path.begin() == "..") { -- cgit v1.2.3