This is an automated email from the ASF dual-hosted git repository. cmcfarlen pushed a commit to branch 10.0.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit 6a9aa76107e623e652255e9b5dd78208167eeb24 Author: Serris Lew <[email protected]> AuthorDate: Tue Jul 9 09:41:53 2024 -0700 traffic_layout: remove directories not in runroot (#11505) Co-authored-by: Serris Lew <[email protected]> (cherry picked from commit 073fb7bea5625fce450d927ee7835369eb1d3019) --- src/traffic_layout/engine.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/traffic_layout/engine.cc b/src/traffic_layout/engine.cc index 7b6d77f571..77a2b07c26 100644 --- a/src/traffic_layout/engine.cc +++ b/src/traffic_layout/engine.cc @@ -386,9 +386,11 @@ LayoutEngine::remove_runroot() } for (const auto &it : map) { std::string dir = it.second; - append_slash(dir); - // get the directory to remove: prefix/etc/trafficserver -> prefix/etc - dir = dir.substr(0, dir.substr(clean_root.size()).find_first_of("/") + clean_root.size()); + if (dir.size() > clean_root.size() && dir.substr(0, clean_root.size()) == clean_root) { + append_slash(dir); + // get the directory to remove: prefix/etc/trafficserver -> prefix/etc + dir = dir.substr(0, dir.substr(clean_root.size()).find_first_of("/") + clean_root.size()); + } // don't remove cwd if (cur_working_dir != dir) { remove_directory(dir);
