mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-08-03 07:26:31 +08:00
add_model_folder_path: ensure unique paths by removing duplicates (#5998)
* add_model_folder_path: ensure unique paths by removing duplicates Signed-off-by: bigcat88 <bigcat88@icloud.com> * refactored "add_model_folder_path" and added tests --------- Signed-off-by: bigcat88 <bigcat88@icloud.com>
This commit is contained in:
@@ -200,10 +200,17 @@ def add_model_folder_path(folder_name: str, full_folder_path: str, is_default: b
|
||||
global folder_names_and_paths
|
||||
folder_name = map_legacy(folder_name)
|
||||
if folder_name in folder_names_and_paths:
|
||||
if is_default:
|
||||
folder_names_and_paths[folder_name][0].insert(0, full_folder_path)
|
||||
paths, _exts = folder_names_and_paths[folder_name]
|
||||
if full_folder_path in paths:
|
||||
if is_default and paths[0] != full_folder_path:
|
||||
# If the path to the folder is not the first in the list, move it to the beginning.
|
||||
paths.remove(full_folder_path)
|
||||
paths.insert(0, full_folder_path)
|
||||
else:
|
||||
folder_names_and_paths[folder_name][0].append(full_folder_path)
|
||||
if is_default:
|
||||
paths.insert(0, full_folder_path)
|
||||
else:
|
||||
paths.append(full_folder_path)
|
||||
else:
|
||||
folder_names_and_paths[folder_name] = ([full_folder_path], set())
|
||||
|
||||
|
Reference in New Issue
Block a user