File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
lib/spack/spack/llnl/util Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -1812,6 +1812,15 @@ def _dedupe_files(paths: List[str]) -> List[str]:
18121812 return unique_files
18131813
18141814
1815+ def _is_root_directory (curr_dir : str ):
1816+ """
1817+ Check if the given directory is the top-level root directory.
1818+ Works on Windows, macOS, and Linux.
1819+ """
1820+ path = pathlib .Path (curr_dir ).resolve ()
1821+ return path == path .anchor or path .parent == path
1822+
1823+
18151824def _find_max_depth (
18161825 roots : Sequence [Path ], globs : Sequence [str ], max_depth : int = sys .maxsize
18171826) -> List [str ]:
@@ -1846,6 +1855,9 @@ def _find_max_depth(
18461855
18471856 while dir_queue :
18481857 depth , curr_dir = dir_queue .pop ()
1858+ # Never traverse root recursively
1859+ if _is_root_directory (curr_dir ):
1860+ continue
18491861 try :
18501862 dir_iter = os .scandir (curr_dir )
18511863 except OSError as e :
You can’t perform that action at this time.
0 commit comments