File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -99,11 +99,18 @@ def chmod_rw(p: str) -> None:
9999 func (path )
100100 return True
101101
102+ def create_long_path (path : Path ) -> Path :
103+ if sys .platform .startswith ("win32" ):
104+ path = path .resolve ()
105+ if not str (path ).startswith (r"\\?" ):
106+ path = Path (r"\\?" + str (path ))
107+ return path
102108
103109def rm_rf (path : Path ) -> None :
104110 """Remove the path contents recursively, even if some elements
105111 are read-only.
106112 """
113+ path = create_long_path (path )
107114 onerror = partial (on_rm_rf_error , start_path = path )
108115 shutil .rmtree (str (path ), onerror = onerror )
109116
Original file line number Diff line number Diff line change @@ -89,3 +89,15 @@ def renamed_failed(*args):
8989 lock_path = get_lock_path (path )
9090 maybe_delete_a_numbered_dir (path )
9191 assert not lock_path .is_file ()
92+
93+ def test_long_path_during_cleanup (tmp_path ):
94+ """Ensure that deleting long path will be able to be deleted"""
95+ path = tmp_path / ("a" * 200 )
96+ if sys .platform == "win32" :
97+ dirname = path .resolve ()
98+ dirname = "\\ \\ ?\\ " + str (path )
99+ os .mkdir (dirname )
100+
101+ lock_path = get_lock_path (path )
102+ maybe_delete_a_numbered_dir (path )
103+ assert not lock_path .is_file ()
You can’t perform that action at this time.
0 commit comments