mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-05-06 16:36:45 -03:00
fix(settings): normalize default root path comparisons
This commit is contained in:
@@ -2,6 +2,7 @@ import asyncio
|
||||
import copy
|
||||
import json
|
||||
import os
|
||||
import posixpath
|
||||
import shutil
|
||||
import tempfile
|
||||
import logging
|
||||
@@ -103,6 +104,15 @@ DEFAULT_SETTINGS: Dict[str, Any] = {
|
||||
}
|
||||
|
||||
|
||||
def _normalize_root_identity(path: str) -> str:
|
||||
"""Normalize a root path for equality checks across slash styles."""
|
||||
|
||||
normalized = posixpath.normpath(path.strip().replace("\\", "/"))
|
||||
if len(normalized) >= 2 and normalized[1] == ":":
|
||||
return normalized.lower()
|
||||
return normalized
|
||||
|
||||
|
||||
class SettingsManager:
|
||||
def __init__(self):
|
||||
self.settings_file = ensure_settings_file(logger)
|
||||
@@ -773,7 +783,7 @@ class SettingsManager:
|
||||
return False
|
||||
|
||||
allowed_roots = self._get_allowed_roots(key)
|
||||
if current and current in allowed_roots:
|
||||
if current and _normalize_root_identity(current) in allowed_roots:
|
||||
return False
|
||||
|
||||
self.settings[setting_key] = primary_candidates[0]
|
||||
@@ -824,16 +834,19 @@ class SettingsManager:
|
||||
if not isinstance(value, str):
|
||||
continue
|
||||
normalized = value.strip()
|
||||
if not normalized or normalized in seen:
|
||||
if not normalized:
|
||||
continue
|
||||
seen.add(normalized)
|
||||
identity = _normalize_root_identity(normalized)
|
||||
if identity in seen:
|
||||
continue
|
||||
seen.add(identity)
|
||||
candidates.append(normalized)
|
||||
return candidates
|
||||
|
||||
def _get_allowed_roots(self, key: str) -> set[str]:
|
||||
"""Return all valid roots for a model type, including extra roots."""
|
||||
|
||||
return set(self._get_valid_root_candidates(key))
|
||||
return {_normalize_root_identity(path) for path in self._get_valid_root_candidates(key)}
|
||||
|
||||
def _check_environment_variables(self) -> None:
|
||||
"""Check for environment variables and update settings if needed"""
|
||||
|
||||
Reference in New Issue
Block a user