diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2023-12-20 16:30:02 +0100 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2023-12-20 16:44:18 +0100 |
commit | 65d99cc2d7b1ea7f2c83c9e4e5ed2fa30c889d18 (patch) | |
tree | 8cb53ac6746217d6e8f1ca2880eb6dc6affc3ddd | |
parent | ae803a336c1af72ba750fc5839bbe3cb20826861 (diff) | |
download | justbuild-65d99cc2d7b1ea7f2c83c9e4e5ed2fa30c889d18.tar.gz |
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.
-rw-r--r-- | src/buildtool/build_engine/base_maps/directory_map.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
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), |