mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-01-25 13:50:15 +08:00
fix: Should gracefully handle missing dirs
This commit is contained in:
parent
98ff01e148
commit
415cb80bd0
@ -93,12 +93,6 @@ def map_legacy(folder_name: str) -> str:
|
|||||||
"clip": "text_encoders"}
|
"clip": "text_encoders"}
|
||||||
return legacy.get(folder_name, folder_name)
|
return legacy.get(folder_name, folder_name)
|
||||||
|
|
||||||
if not os.path.exists(input_directory):
|
|
||||||
try:
|
|
||||||
os.makedirs(input_directory)
|
|
||||||
except:
|
|
||||||
logging.error("Failed to create input directory")
|
|
||||||
|
|
||||||
def set_output_directory(output_dir: str) -> None:
|
def set_output_directory(output_dir: str) -> None:
|
||||||
global output_directory
|
global output_directory
|
||||||
output_directory = output_dir
|
output_directory = output_dir
|
||||||
|
|||||||
24
main.py
24
main.py
@ -55,6 +55,21 @@ def apply_custom_paths():
|
|||||||
folder_paths.set_user_directory(user_dir)
|
folder_paths.set_user_directory(user_dir)
|
||||||
|
|
||||||
|
|
||||||
|
# These are created at startup if missing. Other data directories are created on-demand when needed.
|
||||||
|
def create_data_folders():
|
||||||
|
data_dirs = [
|
||||||
|
folder_paths.get_input_directory(),
|
||||||
|
folder_paths.get_temp_directory()
|
||||||
|
]
|
||||||
|
|
||||||
|
for dir_path in data_dirs:
|
||||||
|
if not os.path.exists(dir_path):
|
||||||
|
try:
|
||||||
|
os.makedirs(dir_path)
|
||||||
|
except:
|
||||||
|
logging.error(f"Failed to create directory: {dir_path}")
|
||||||
|
|
||||||
|
|
||||||
def execute_prestartup_script():
|
def execute_prestartup_script():
|
||||||
def execute_script(script_path):
|
def execute_script(script_path):
|
||||||
module_name = os.path.splitext(script_path)[0]
|
module_name = os.path.splitext(script_path)[0]
|
||||||
@ -72,7 +87,11 @@ def execute_prestartup_script():
|
|||||||
|
|
||||||
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)
|
if not os.path.exists(custom_node_path):
|
||||||
|
logging.warning(f"Directory {custom_node_path} for custom nodes does not exist, skipping")
|
||||||
|
continue
|
||||||
|
|
||||||
|
possible_modules = os.listdir(os.path.realpath(custom_node_path))
|
||||||
node_prestartup_times = []
|
node_prestartup_times = []
|
||||||
|
|
||||||
for possible_module in possible_modules:
|
for possible_module in possible_modules:
|
||||||
@ -95,7 +114,9 @@ def execute_prestartup_script():
|
|||||||
logging.info("{:6.1f} seconds{}: {}".format(n[0], import_message, n[1]))
|
logging.info("{:6.1f} seconds{}: {}".format(n[0], import_message, n[1]))
|
||||||
logging.info("")
|
logging.info("")
|
||||||
|
|
||||||
|
|
||||||
apply_custom_paths()
|
apply_custom_paths()
|
||||||
|
create_data_folders()
|
||||||
execute_prestartup_script()
|
execute_prestartup_script()
|
||||||
|
|
||||||
|
|
||||||
@ -283,7 +304,6 @@ def start_comfyui(asyncio_loop=None):
|
|||||||
if args.quick_test_for_ci:
|
if args.quick_test_for_ci:
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
os.makedirs(folder_paths.get_temp_directory(), exist_ok=True)
|
|
||||||
call_on_start = None
|
call_on_start = None
|
||||||
if args.auto_launch:
|
if args.auto_launch:
|
||||||
def startup_server(scheme, address, port):
|
def startup_server(scheme, address, port):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user