mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-09-21 03:01:27 -03:00
fix(other-models): default downloads to a flat path, not {base_model}/{first_tag}
get_download_path_template() fell back to "{base_model}/{first_tag}" for any
unconfigured model type, so other-model downloads were silently nested under an
arbitrary CivitAI tag even though the settings UI exposes no template row for
"other" and priority_tags has no "other" entry (making {first_tag} resolve to
tags[0]).
Add DEFAULT_DOWNLOAD_PATH_TEMPLATES with other -> "" so unconfigured and
unknown types resolve to a flat layout under the already sub_type-scoped
default_other_roots; explicit settings.json values still win. Mirror the flat
default in the frontend DEFAULT_PATH_TEMPLATES and stop the download/move
default-path previews from rendering "/undefined" or a dangling slash.
This commit is contained in:
@@ -428,6 +428,29 @@ async def test_default_paths_use_per_sub_type_root(
|
||||
|
||||
assert result["success"] is True
|
||||
assert str(tmp_path / "vae") in str(captured["save_dir"])
|
||||
assert captured["relative_path"] == ""
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_default_paths_other_is_flat_without_configured_template(
|
||||
monkeypatch, scanners, metadata_provider, tmp_path
|
||||
):
|
||||
"""Regression: an unconfigured 'other' template must resolve to a flat
|
||||
layout at the sub_type root instead of the {base_model}/{first_tag}
|
||||
fallback (which scattered files into arbitrary CivitAI-tag folders)."""
|
||||
get_settings_manager().settings["download_path_templates"].pop("other", None)
|
||||
|
||||
captured = {}
|
||||
_capture_execute(monkeypatch, captured)
|
||||
|
||||
manager = DownloadManager()
|
||||
result = await manager.download_from_civitai(
|
||||
model_version_id=99, use_default_paths=True
|
||||
)
|
||||
|
||||
assert result["success"] is True
|
||||
assert captured["relative_path"] == ""
|
||||
assert str(tmp_path / "vae") in str(captured["save_dir"])
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
@@ -345,6 +345,26 @@ def test_download_path_template_invalid_json(manager):
|
||||
)
|
||||
|
||||
|
||||
def test_download_path_template_defaults_flat_for_other(manager):
|
||||
"""'other' has no settings-UI row and no priority_tags entry, so an
|
||||
unconfigured template must resolve to a flat layout rather than the
|
||||
{base_model}/{first_tag} fallback (which scatters files into arbitrary
|
||||
CivitAI-tag folders)."""
|
||||
manager.settings["download_path_templates"] = {}
|
||||
|
||||
assert manager.get_download_path_template("other") == ""
|
||||
|
||||
# An explicit user configuration still wins.
|
||||
manager.settings["download_path_templates"] = {"other": "{base_model}"}
|
||||
assert manager.get_download_path_template("other") == "{base_model}"
|
||||
|
||||
|
||||
def test_download_path_template_unknown_type_is_flat(manager):
|
||||
manager.settings["download_path_templates"] = {}
|
||||
|
||||
assert manager.get_download_path_template("not-a-model-type") == ""
|
||||
|
||||
|
||||
def test_auto_set_default_roots(manager):
|
||||
# Clear any previously auto-set values to test fresh behavior
|
||||
manager.settings["default_lora_root"] = ""
|
||||
|
||||
Reference in New Issue
Block a user