From 65d99cc2d7b1ea7f2c83c9e4e5ed2fa30c889d18 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Wed, 20 Dec 2023 16:30:02 +0100 Subject: directory_map: refuse to read contents of absent roots While in our setting, a missing directory is generally OK, it is not OK to ask for the content of an absent root. In particular, we should not assume it to be empty, just because the root is absent. --- src/buildtool/build_engine/base_maps/directory_map.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') diff --git a/src/buildtool/build_engine/base_maps/directory_map.cpp b/src/buildtool/build_engine/base_maps/directory_map.cpp index da360e4e..be77dee3 100644 --- a/src/buildtool/build_engine/base_maps/directory_map.cpp +++ b/src/buildtool/build_engine/base_maps/directory_map.cpp @@ -36,6 +36,18 @@ auto BuildMaps::Base::CreateDirectoryEntriesMap( true); return; } + if (ws_root->IsAbsent()) { + std::string missing_root = "[unknown]"; + auto absent_tree = ws_root->GetAbsentTreeId(); + if (absent_tree) { + missing_root = *absent_tree; + } + (*logger)(fmt::format("Would have to read directory entries of " + "absent root {}.", + missing_root), + true); + return; + } auto dir_path = key.module.empty() ? "." : key.module; if (not ws_root->IsDirectory(dir_path)) { // Missing directory is fine (source tree might be incomplete), -- cgit v1.2.3