@@ -51,7 +51,7 @@ def __init__(
5151 copy_from_current_on_enter : bool = False ,
5252 copy_to_current_on_exit : bool = False ,
5353 gzip_on_exit : bool = False ,
54- delete_removed_files : bool = False ,
54+ delete_removed_files : bool | None = None ,
5555 ) -> None :
5656 """
5757 Initializes scratch directory given a **root** path. There is no need
@@ -83,10 +83,15 @@ def __init__(
8383 gzip_on_exit (bool): Whether to gzip the files generated in the
8484 ScratchDir before copying them back.
8585 Defaults to False.
86- delete_removed_files (bool): Whether to delete files in the cwd
87- that are not present in the tmp dir. WARNING: this could
88- wipe your CWD. Defaults to False..
86+ delete_removed_files (bool): Deprecated, don't use.
8987 """
88+ if delete_removed_files is not None :
89+ warnings .warn (
90+ "delete_removed_files is deprecated and would have no effect" ,
91+ DeprecationWarning ,
92+ stacklevel = 2 ,
93+ )
94+
9095 self .cwd : str = os .getcwd ()
9196 self .rootpath : str | None = (
9297 None if rootpath is None else os .path .abspath (rootpath )
@@ -105,7 +110,6 @@ def __init__(
105110 self .enter_copy : bool = copy_from_current_on_enter
106111 self .exit_copy : bool = copy_to_current_on_exit
107112 self .gzip_on_exit : bool = gzip_on_exit
108- self .delete_removed_files : bool = delete_removed_files
109113
110114 def __enter__ (self ) -> str :
111115 tempdir : str = self .cwd
@@ -122,9 +126,6 @@ def __enter__(self) -> str:
122126 def __exit__ (self , exc_type , exc_val , exc_tb ) -> None :
123127 if not self .pass_through :
124128 if self .exit_copy :
125- files = set (os .listdir (self .tempdir ))
126- orig_files = set (os .listdir (self .cwd ))
127-
128129 # gzip files
129130 if self .gzip_on_exit :
130131 gzip_dir (self .tempdir )
@@ -175,12 +176,6 @@ def get_modif_times(
175176 # copy files over
176177 shutil .copytree (self .tempdir , self .cwd , dirs_exist_ok = True )
177178
178- # Delete any files that are now gone
179- if self .delete_removed_files :
180- for f in orig_files - files :
181- fpath = os .path .join (self .cwd , f )
182- remove (fpath )
183-
184179 os .chdir (self .cwd )
185180 remove (self .tempdir )
186181 if self .create_symbolic_link and os .path .islink (ScratchDir .SCR_LINK ):
0 commit comments