This is an automated email from the ASF dual-hosted git repository.

lserris pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 073fb7bea5 traffic_layout: remove directories not in runroot (#11505)
073fb7bea5 is described below

commit 073fb7bea5625fce450d927ee7835369eb1d3019
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]>
---
 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);

Reply via email to