Revert folder_paths.py changes.

This commit is contained in:
filtered 2025-01-28 23:19:02 +11:00
parent 87dcae08d9
commit 9ffa089474

View File

@ -10,40 +10,8 @@ from collections.abc import Collection
supported_pt_extensions: set[str] = {'.ckpt', '.pt', '.bin', '.pth', '.safetensors', '.pkl', '.sft'} supported_pt_extensions: set[str] = {'.ckpt', '.pt', '.bin', '.pth', '.safetensors', '.pkl', '.sft'}
folder_names_and_paths: dict[str, tuple[list[str], set[str]]] = {} folder_names_and_paths: dict[str, tuple[list[str], set[str]]] = {}
filename_list_cache: dict[str, tuple[list[str], dict[str, float], float]] = {}
base_path = os.path.dirname(os.path.realpath(__file__))
def reset_all_paths(new_base_path: str) -> None:
"""
Internal use only. Designed for use immediately after startup.
Removes all existing known paths, clears the filename cache, and creates the defaults under a new base path.
Paths:
- All default model paths
- input
- output
- temp
- user
- custom_nodes
Also creates the input directory if missing.
Args:
new_base_path: The base path to prepend to all default relative paths.
"""
global base_path
global models_dir
global output_directory
global temp_directory
global input_directory
global user_directory
filename_list_cache.clear()
folder_names_and_paths.clear()
base_path = new_base_path
models_dir = os.path.join(base_path, "models") models_dir = os.path.join(base_path, "models")
folder_names_and_paths["checkpoints"] = ([os.path.join(models_dir, "checkpoints")], supported_pt_extensions) 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"]) folder_names_and_paths["configs"] = ([os.path.join(models_dir, "configs")], [".yaml"])
@ -76,17 +44,7 @@ def reset_all_paths(new_base_path: str) -> None:
input_directory = os.path.join(base_path, "input") input_directory = os.path.join(base_path, "input")
user_directory = os.path.join(base_path, "user") user_directory = os.path.join(base_path, "user")
# Create input dir if it does not already exist. filename_list_cache: dict[str, tuple[list[str], dict[str, float], float]] = {}
if not os.path.exists(input_directory):
try:
os.makedirs(input_directory)
except:
logging.error("Failed to create input directory")
# Default configuration: add all paths relative to this file.
reset_all_paths(os.path.dirname(os.path.realpath(__file__)))
class CacheHelper: class CacheHelper:
""" """
@ -127,6 +85,12 @@ 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