mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-10-12 12:32:11 -03:00
fix(paths): keep business paths forward-slashed on Windows
Four places produced the host's separator (or a mixed path) where the app's
business form is forward-slashed, so on Windows the value could not be compared
with the one the rest of the app stores:
* `ModelScanner._calculate_folder` matched `file_path.startswith(root)` as raw
strings, so every forward-slashed path resolved to the library root and a
moved model was filed under the root instead of its folder. It now compares
root identities and slices the relative part off.
* `normalize_relative_folder` ran `os.path.normpath`, and ntpath folds forward
slashes back to backslashes: every folder parameter (scoped scan, create,
rename, delete) came back host-spelled and mismatched the stored folders.
* `_format_model_name_for_comfyui` returned `os.path.relpath` unchanged, so the
checkpoint/unet nodes and the metadata node emitted `unet\base.safetensors`
on Windows -- a name no ComfyUI widget list matches.
* `resolve_centralized_dir_for_dir` passed a component that spans two
directories ("<library>/<component>") whole to `os.path.join`, leaving a mixed
path ("...\comfyui/loras-1a2b3c4d\sub") that no native path equals.
Also hands the rename re-key callback business paths, like every other absolute
path the move service returns.
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import asyncio
|
||||
import fnmatch
|
||||
import os
|
||||
import logging
|
||||
import os
|
||||
import posixpath
|
||||
import shutil
|
||||
from typing import Any, Dict, List, Optional, Sequence, Set
|
||||
from abc import ABC, abstractmethod
|
||||
@@ -36,12 +37,11 @@ def normalize_relative_folder(folder: str) -> str:
|
||||
if normalized.startswith("/") or (len(normalized) > 1 and normalized[1] == ":"):
|
||||
raise ValueError("Folder path must be relative to a library root")
|
||||
|
||||
normalized = os.path.normpath(normalized)
|
||||
if (
|
||||
normalized == ".."
|
||||
or normalized.startswith("../")
|
||||
or normalized.startswith(".." + os.sep)
|
||||
):
|
||||
# posixpath, not os.path: ntpath.normpath would fold the business form back
|
||||
# to backslashes, and every stored folder, cache entry and comparison in the
|
||||
# app is forward-slashed.
|
||||
normalized = posixpath.normpath(normalized)
|
||||
if normalized == ".." or normalized.startswith("../"):
|
||||
raise ValueError("Folder path must stay inside the library root")
|
||||
|
||||
return normalized
|
||||
@@ -1062,7 +1062,12 @@ class ModelMoveService:
|
||||
|
||||
new_relative = self._calculate_relative_folder(target)
|
||||
await self._rename_folder_records(
|
||||
previous_relative, new_relative, absolute_path, target
|
||||
previous_relative,
|
||||
new_relative,
|
||||
# Business paths, like every other absolute path this service
|
||||
# hands out: the scanner re-keys cache entries by prefix.
|
||||
absolute_path.replace(os.sep, "/"),
|
||||
target.replace(os.sep, "/"),
|
||||
)
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user