mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-06-09 20:39:25 -03:00
fix(scripts): use platformdirs for cross-platform settings path resolution
Both restore_suffixed_filenames.py and migrate_legacy_metadata.py hardcoded Path.home() / '.config' / APP_NAME for finding settings.json, which only works on Linux. On Windows this resolves to the wrong path (~/.config/ instead of %LOCALAPPDATA%). Replace the hand-rolled fallback with platformdirs.user_config_dir(), which correctly resolves to the OS-appropriate config directory on all platforms (Windows: %%LOCALAPPDATA%%, macOS: ~/Library/Application Support, Linux: ~/.config). The portable mode check (settings.json in repo root with use_portable_settings: true) is preserved unchanged.
This commit is contained in:
@@ -34,6 +34,8 @@ import sys
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
from platformdirs import user_config_dir
|
||||||
|
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
level=logging.INFO,
|
level=logging.INFO,
|
||||||
format="%(asctime)s - %(levelname)s - %(message)s",
|
format="%(asctime)s - %(levelname)s - %(message)s",
|
||||||
@@ -53,10 +55,7 @@ def resolve_settings_path() -> Path:
|
|||||||
if isinstance(payload, dict) and payload.get("use_portable_settings") is True:
|
if isinstance(payload, dict) and payload.get("use_portable_settings") is True:
|
||||||
return portable
|
return portable
|
||||||
|
|
||||||
config_home = os.environ.get("XDG_CONFIG_HOME")
|
return Path(user_config_dir(APP_NAME, appauthor=False)) / "settings.json"
|
||||||
if config_home:
|
|
||||||
return Path(config_home).expanduser() / APP_NAME / "settings.json"
|
|
||||||
return Path.home() / ".config" / APP_NAME / "settings.json"
|
|
||||||
|
|
||||||
|
|
||||||
def load_json(path: Path) -> dict[str, Any]:
|
def load_json(path: Path) -> dict[str, Any]:
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ import sys
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
from platformdirs import user_config_dir
|
||||||
|
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
level=logging.INFO,
|
level=logging.INFO,
|
||||||
format="%(message)s",
|
format="%(message)s",
|
||||||
@@ -68,10 +70,7 @@ def resolve_settings_path() -> Path:
|
|||||||
if isinstance(payload, dict) and payload.get("use_portable_settings") is True:
|
if isinstance(payload, dict) and payload.get("use_portable_settings") is True:
|
||||||
return portable
|
return portable
|
||||||
|
|
||||||
config_home = os.environ.get("XDG_CONFIG_HOME")
|
return Path(user_config_dir(APP_NAME, appauthor=False)) / "settings.json"
|
||||||
if config_home:
|
|
||||||
return Path(config_home).expanduser() / APP_NAME / "settings.json"
|
|
||||||
return Path.home() / ".config" / APP_NAME / "settings.json"
|
|
||||||
|
|
||||||
|
|
||||||
def _load_json(path: Path) -> dict[str, Any]:
|
def _load_json(path: Path) -> dict[str, Any]:
|
||||||
|
|||||||
Reference in New Issue
Block a user