feat: Simplify custom nodes whitelist logic to use consistent code paths

This commit is contained in:
lgldlk 2025-06-25 17:19:07 +08:00
parent a335e31ded
commit 55e69ac9b8
2 changed files with 1 additions and 6 deletions

View File

@ -66,9 +66,6 @@ def execute_prestartup_script():
logging.error(f"Failed to execute startup-script: {script_path} / {e}") logging.error(f"Failed to execute startup-script: {script_path} / {e}")
return False return False
if args.disable_all_custom_nodes and not args.whitelist_custom_nodes:
return
node_paths = folder_paths.get_folder_paths("custom_nodes") node_paths = folder_paths.get_folder_paths("custom_nodes")
for custom_node_path in node_paths: for custom_node_path in node_paths:
possible_modules = os.listdir(custom_node_path) possible_modules = os.listdir(custom_node_path)
@ -274,7 +271,7 @@ def start_comfyui(asyncio_loop=None):
hook_breaker_ac10a0.save_functions() hook_breaker_ac10a0.save_functions()
nodes.init_extra_nodes( nodes.init_extra_nodes(
init_custom_nodes=(not args.disable_all_custom_nodes) or bool(args.whitelist_custom_nodes), init_custom_nodes=True,
init_api_nodes=not args.disable_api_nodes init_api_nodes=not args.disable_api_nodes
) )
hook_breaker_ac10a0.restore_functions() hook_breaker_ac10a0.restore_functions()

View File

@ -2187,11 +2187,9 @@ def init_external_custom_nodes():
module_path = os.path.join(custom_node_path, possible_module) module_path = os.path.join(custom_node_path, possible_module)
if os.path.isfile(module_path) and os.path.splitext(module_path)[1] != ".py": continue if os.path.isfile(module_path) and os.path.splitext(module_path)[1] != ".py": continue
if module_path.endswith(".disabled"): continue if module_path.endswith(".disabled"): continue
if args.disable_all_custom_nodes and possible_module not in args.whitelist_custom_nodes: if args.disable_all_custom_nodes and possible_module not in args.whitelist_custom_nodes:
logging.info(f"Skipping {possible_module} due to disable_all_custom_nodes and whitelist_custom_nodes") logging.info(f"Skipping {possible_module} due to disable_all_custom_nodes and whitelist_custom_nodes")
continue continue
time_before = time.perf_counter() time_before = time.perf_counter()
success = load_custom_node(module_path, base_node_names, module_parent="custom_nodes") success = load_custom_node(module_path, base_node_names, module_parent="custom_nodes")
node_import_times.append((time.perf_counter() - time_before, module_path, success)) node_import_times.append((time.perf_counter() - time_before, module_path, success))