mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-21 21:22:11 -03:00
fix(config): remove template default library before saving paths
This commit is contained in:
@@ -6,7 +6,7 @@ import json
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
from typing import Optional
|
||||
from typing import Any, Dict, Optional
|
||||
|
||||
from platformdirs import user_config_dir
|
||||
|
||||
@@ -124,3 +124,32 @@ def _should_use_portable_settings(path: str, logger: logging.Logger) -> bool:
|
||||
)
|
||||
return False
|
||||
|
||||
|
||||
def load_settings_template() -> Optional[Dict[str, Any]]:
|
||||
"""Return the parsed contents of ``settings.json.example`` when available."""
|
||||
|
||||
template_path = os.path.join(get_project_root(), "settings.json.example")
|
||||
|
||||
try:
|
||||
with open(template_path, "r", encoding="utf-8") as handle:
|
||||
payload = json.load(handle)
|
||||
except FileNotFoundError:
|
||||
_LOGGER.debug("settings.json.example not found at %s", template_path)
|
||||
return None
|
||||
except json.JSONDecodeError as exc:
|
||||
_LOGGER.warning("Failed to parse settings.json.example: %s", exc)
|
||||
return None
|
||||
except OSError as exc:
|
||||
_LOGGER.warning(
|
||||
"Could not read settings.json.example at %s: %s", template_path, exc
|
||||
)
|
||||
return None
|
||||
|
||||
if not isinstance(payload, dict):
|
||||
_LOGGER.debug(
|
||||
"settings.json.example at %s does not contain a JSON object", template_path
|
||||
)
|
||||
return None
|
||||
|
||||
return payload
|
||||
|
||||
|
||||
Reference in New Issue
Block a user