File tree Expand file tree Collapse file tree
src/ducktools/pythonfinder Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -80,12 +80,15 @@ def get_path_pythons(
8080 if not os .path .exists (fld ):
8181 continue
8282
83- for install in get_folder_pythons (fld , finder = finder ):
84- for path , manager in known_paths .items ():
85- if os .path .commonpath ((path , install .executable )) == path :
86- install .managed_by = manager
87- break
83+ # Do the search like this to get subfolders
84+ for path , manager in known_paths .items ():
85+ if os .path .commonpath ((path , fld )) == path :
86+ managed_by = manager
87+ break
88+ else :
89+ managed_by = None
8890
91+ for install in get_folder_pythons (fld , finder = finder , managed_by = managed_by ):
8992 name = os .path .basename (install .executable )
9093 if name in exe_names :
9194 install .shadowed = True
Original file line number Diff line number Diff line change @@ -291,16 +291,21 @@ def get_install_details(
291291 exe_path = os .path .abspath (exe_path )
292292 mtime = os .stat (exe_path ).st_mtime
293293
294+ # If the mtime of the file has been set to 0
295+ # it is not possible to reliably cache install details
296+ cacheable_install = (mtime != 0 )
297+
294298 install = None
295299 if cached_details := self .raw_cache .get (exe_path ):
296- if cached_details ["mtime" ] == mtime :
300+ if cacheable_install and cached_details ["mtime" ] == mtime :
297301 install = PythonInstall .from_json (** cached_details ["install" ])
298302 else :
299303 self .raw_cache .pop (exe_path )
304+ self ._dirty_cache = True
300305
301306 if install is None :
302307 install = self .query_install (exe_path , managed_by , metadata )
303- if install :
308+ if install and cacheable_install :
304309 self .raw_cache [exe_path ] = {
305310 "mtime" : mtime ,
306311 "install" : as_dict (install )
You can’t perform that action at this time.
0 commit comments