Cached scanned filenames until next object_info call

This commit is contained in:
space-nuko 2023-05-09 22:30:36 -05:00
parent 314e526c5c
commit a66309e0e2
2 changed files with 16 additions and 6 deletions

View File

@ -139,12 +139,21 @@ def get_full_path(folder_name, filename):
return full_path
filename_list_cache = {}
def clear_cache():
filename_list_cache = {}
def get_filename_list(folder_name):
global folder_names_and_paths
output_list = set()
folders = folder_names_and_paths[folder_name]
for x in folders[0]:
output_list.update(filter_files_extensions(recursive_search(x), folders[1]))
return sorted(list(output_list))
global folder_names_and_paths, cache
if folder_name not in filename_list_cache:
output_list = set()
folders = folder_names_and_paths[folder_name]
for x in folders[0]:
output_list.update(filter_files_extensions(recursive_search(x), folders[1]))
filename_list_cache[folder_name] = sorted(list(output_list))
return filename_list_cache[folder_name]

View File

@ -257,6 +257,7 @@ class PromptServer():
@routes.get("/object_info")
async def get_object_info(request):
folder_paths.clear_cache()
out = {}
for x in nodes.NODE_CLASS_MAPPINGS:
obj_class = nodes.NODE_CLASS_MAPPINGS[x]