Compare commits

...

4 Commits

Author SHA1 Message Date
samith
d982b4100c
Merge 3c3d7feefe into b08debceca 2026-07-06 17:34:03 +08:00
samith
3c3d7feefe
Update folder_paths.py
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2026-07-04 22:03:02 +05:30
samith
a2b56d8c1f fix: correct file path for loading redirects in valid_path function 2026-07-04 21:46:12 +05:30
samith
744d56261b fix: enhance path validation and redirection for model directories 2026-07-04 21:30:39 +05:30

View File

@ -4,7 +4,7 @@ import mimetypes
import logging
from typing import Literal, List
from collections.abc import Collection
import json
from comfy.cli_args import args
supported_pt_extensions: set[str] = {'.ckpt', '.pt', '.pt2', '.bin', '.pth', '.safetensors', '.pkl', '.sft'}
@ -13,11 +13,38 @@ folder_names_and_paths: dict[str, tuple[list[str], set[str]]] = {}
# --base-directory - Resets all default paths configured in folder_paths with a new base path
if args.base_directory:
base_path = os.path.abspath(args.base_directory)
raw_path = os.path.abspath(args.base_directory)
else:
base_path = os.path.dirname(os.path.realpath(__file__))
raw_path = os.path.dirname(os.path.realpath(__file__))
models_dir = os.path.join(base_path, "models")
def valid_path(saved_path,description = "Instance Folder"):
if os.path.exists(saved_path):
return saved_path
redirect_path = os.path.join(os.path.dirname(__file__),"path.redirects.json")
if os.path.exists(redirect_path):
with open(redirect_path,"r") as f:
redirects = json.load(f)
if description in redirects and os.path.exists(redirects[description]):
return redirects[description]
print(f"\n[!] ALERT: {description} not found at: {saved_path}")
new_path= input(f"Please paste the updated absolute path for '{description}': ").strip()
redirects = {}
if os.path.exists(redirect_path):
with open(redirect_path, "r") as f:
redirects = json.load(f)
redirects[description] = new_path
with open(redirect_path, "w") as f:
json.dump(redirects, f, indent=4)
return new_path
base_path = valid_path(raw_path,description = "ComfyUI Core Directory")
models_dir =valid_path( os.path.join(base_path,"models"),description = "Model Directory")
folder_names_and_paths["checkpoints"] = ([os.path.join(models_dir, "checkpoints")], supported_pt_extensions)
folder_names_and_paths["configs"] = ([os.path.join(models_dir, "configs")], [".yaml"])
@ -60,7 +87,7 @@ folder_names_and_paths["optical_flow"] = ([os.path.join(models_dir, "optical_flo
folder_names_and_paths["detection"] = ([os.path.join(models_dir, "detection")], supported_pt_extensions)
output_directory = os.path.join(base_path, "output")
output_directory =valid_path( os.path.join(base_path, "output"),"Output Directory")
temp_directory = os.path.join(base_path, "temp")
input_directory = os.path.join(base_path, "input")
user_directory = os.path.join(base_path, "user")