File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 33import copy
44import os
55import shutil
6+ import tempfile
67import secrets
78from contextlib import AsyncExitStack , asynccontextmanager
89from inspect import signature
@@ -216,14 +217,21 @@ def __init__(
216217 )
217218
218219 def __del__ (self ):
220+ current_temp_dir = os .path .realpath (tempfile .gettempdir ())
221+
219222 user_dependencies = [
220223 v .source ["subdir" ]
221224 for k , v in self ._registered_dependencies .items ()
222225 if k .startswith ("include-" )
223226 ]
224227
225228 for item in user_dependencies :
226- if os .path .exists (item ):
229+ # Only remove the item if it exists and it is in the current temp directory
230+ if (
231+ os .path .exists (item )
232+ and os .path .commonprefix ([os .path .realpath (item ), current_temp_dir ])
233+ == current_temp_dir
234+ ):
227235 print ("Removing dependency: " , item )
228236 shutil .rmtree (item )
229237
You can’t perform that action at this time.
0 commit comments