Resolve symlinks (and userdirs) when looking for lora files reported by ComfyUI. Addresses #574

This commit is contained in:
rgthree
2025-11-10 23:55:04 -05:00
parent 9d8164edfc
commit 68fe47c0e8
4 changed files with 12 additions and 7 deletions
+2 -3
View File
@@ -6,7 +6,7 @@ from ..log import log
from server import PromptServer
import folder_paths
from ..utils import path_exists
from ..utils import abspath, path_exists
from .utils_server import get_param, is_param_falsy
from .utils_info import delete_model_info, get_model_info, set_model_info_partial, get_file_info
@@ -159,8 +159,7 @@ async def api_get_models_info_img(request):
file_param = get_param(request, 'file')
file_path = folder_paths.get_full_path(model_type, file_param)
if not path_exists(file_path):
file_path = os.path.abspath(file_path)
file_path = abspath(file_path)
img_path = None
for ext in ['jpg', 'png', 'jpeg']:
try_path = f'{os.path.splitext(file_path)[0]}.{ext}'
+3 -3
View File
@@ -9,7 +9,7 @@ import requests
from server import PromptServer
import folder_paths
from ..utils import get_dict_value, load_json_file, file_exists, remove_path, save_json_file
from ..utils import abspath, get_dict_value, load_json_file, file_exists, remove_path, save_json_file
from ..utils_userdata import read_userdata_json, save_userdata_json, delete_userdata_file
@@ -414,8 +414,8 @@ def _read_file_metadata_from_header(file_path: str) -> dict:
def get_folder_path(file: str, model_type) -> str | None:
"""Gets the file path ensuring it exists."""
file_path = folder_paths.get_full_path(model_type, file)
if file_path and not file_exists(file_path):
file_path = os.path.abspath(file_path)
if not file_exists(file_path):
filepath = abspath(file_path)
if not file_exists(file_path):
file_path = None
return file_path
+6
View File
@@ -150,6 +150,12 @@ def remove_path(path):
return True
return False
def abspath(file_path: str):
"""Resolves the abspath of a file, resolving symlinks and user dirs."""
if not path_exists(file_path):
maybe_path = os.path.abspath(os.path.realpath(os.path.expanduser(file_path)))
file_path = maybe_path if path_exists(maybe_path) else file_path
return file_path
class ByPassTypeTuple(tuple):
"""A special class that will return additional "AnyType" strings beyond defined values.
+1 -1
View File
@@ -1,7 +1,7 @@
[project]
name = "rgthree-comfy"
description = "Making ComfyUI more comfortable."
version = "1.0.2511091959"
version = "1.0.2511102355"
license = { file = "LICENSE" }
dependencies = []