mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-09-20 18:51:26 -03:00
feat(settings): add an explicit opt-out from persisted portable mode
Setting LORA_MANAGER_PORTABLE=1 once wrote use_portable_settings: true into the plugin's own settings.json, and every later run of every instance sharing that plugin folder then read and wrote the portable settings directory. There was no way back except editing the file by hand, which is exactly the trap a user hit while following the FAQ's instructions for isolating a second instance (#1114). LORA_MANAGER_PORTABLE=0 is now the explicit exit: - _should_use_portable_settings honours "0" as a forced off, so the resolved settings directory no longer depends on the persisted flag. - SettingsManager clears the persisted flag in that case, so later runs without the variable stay on the shared settings directory. Unset or unrecognised values keep the previous behaviour: the persisted flag decides, so existing portable installs are unaffected. LORA_MANAGER_SETTINGS_DIR still takes precedence over both.
This commit is contained in:
@@ -37,6 +37,7 @@ from ..utils.constants import (
|
||||
from ..utils.preview_selection import VALID_MATURE_BLUR_LEVELS
|
||||
from ..utils.settings_paths import (
|
||||
APP_NAME,
|
||||
_portable_env_override,
|
||||
ensure_settings_file,
|
||||
get_legacy_settings_path,
|
||||
get_settings_dir_override,
|
||||
@@ -172,13 +173,23 @@ class SettingsManager:
|
||||
self._check_environment_variables()
|
||||
self._collect_configuration_warnings()
|
||||
|
||||
if (
|
||||
os.environ.get("LORA_MANAGER_PORTABLE", "0") == "1"
|
||||
and not is_settings_dir_pinned()
|
||||
):
|
||||
portable_override = _portable_env_override()
|
||||
if portable_override is True and not is_settings_dir_pinned():
|
||||
if not self.settings.get("use_portable_settings"):
|
||||
self.settings["use_portable_settings"] = True
|
||||
self._save_settings()
|
||||
elif portable_override is False and self.settings.get(
|
||||
"use_portable_settings"
|
||||
):
|
||||
# Explicit opt-out from a persisted portable mode: clear the flag so
|
||||
# later runs go back to the shared settings directory instead of
|
||||
# requiring a manual edit of settings.json.
|
||||
logger.info(
|
||||
"Clearing the persisted portable-mode flag because %s=0",
|
||||
"LORA_MANAGER_PORTABLE",
|
||||
)
|
||||
self.settings["use_portable_settings"] = False
|
||||
self._save_settings()
|
||||
|
||||
if self._needs_initial_save:
|
||||
self._save_settings()
|
||||
|
||||
Reference in New Issue
Block a user