Fix path parsing issue in _get_models function (#77)

- Clean escaped characters and quotes from git ls-files output
- Add safety check to skip non-existent files
- Fixes FileNotFoundError when model paths contain escaped characters

Resolves issue where comfy-pack API would fail with:
FileNotFoundError: [Errno 2] No such file or directory: '.../models/loras/wan/wan\\WAN2.1_...'
This commit is contained in:
halfaipg
2025-09-25 09:34:35 +08:00
committed by GitHub
parent b44f81e4d1
commit 5f9c5f5dad
+6 -2
View File
@@ -132,9 +132,9 @@ async def _get_models(
models = []
model_filenames = [
os.path.abspath(line)
os.path.abspath(line.strip().strip('"').replace('\\\\', '/'))
for line in stdout.decode().splitlines()
if not os.path.basename(line).startswith(".")
if not os.path.basename(line.strip().strip('"').replace('\\\\', '/')).startswith(".")
]
model_hashes = await async_batch_get_sha256(
model_filenames,
@@ -142,6 +142,10 @@ async def _get_models(
)
for filename in model_filenames:
# Skip if file doesn't exist
if not os.path.exists(filename):
continue
relpath = os.path.relpath(filename, folder_paths.base_path)
model_data = {