mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-09-23 12:04:09 -03:00
fix(organize): exclude Civitai meta tags from folder names (#1119)
Follow-up to the keyword-dump guard. The reported model's tag list is ["lora, character, ... face", "base model"], so skipping the dump left the "base model" label to be picked as the folder name. That label describes Civitai's listing rather than the model's content, which makes it as meaningless as a folder as the blob was. Add CIVITAI_META_TAGS and is_civitai_meta_tag(), and skip those labels in the automatic fallback. An explicit priority entry still matches them, so a user who does want a "base model" folder can configure one. The reported model now resolves to "Krea 2/no tags" instead of "Krea 2/base model". Also correct a comment that listed ".civitai.info" among the files sitting next to a model. LoRA Manager only reads that sidecar -- other tools write it -- and writes ".metadata.json" itself.
This commit is contained in:
@@ -239,7 +239,11 @@ async def test_successful_download_uses_defaults(
|
||||
|
||||
|
||||
def test_calculate_relative_path_ignores_keyword_dump_tag():
|
||||
"""The #1119 download flow: a keyword-dump tag must not become a folder."""
|
||||
"""The #1119 download flow: the real tag list must not become a folder.
|
||||
|
||||
The model's only two tags are the keyword dump and Civitai's "base model"
|
||||
label, so nothing usable is left and the template falls back to "no tags".
|
||||
"""
|
||||
keyword_dump = (
|
||||
"lora, character, rosie, irish, redhead, auburn, freckles, green eyes, "
|
||||
"curly hair, woman, female, photorealistic, realistic, krea2, dark beast, "
|
||||
@@ -257,7 +261,7 @@ def test_calculate_relative_path_ignores_keyword_dump_tag():
|
||||
"lora",
|
||||
)
|
||||
|
||||
assert relative_path == "MappedModel/base model"
|
||||
assert relative_path == "MappedModel/no tags"
|
||||
assert keyword_dump not in relative_path
|
||||
assert len(relative_path) < 50
|
||||
|
||||
|
||||
@@ -412,6 +412,40 @@ def test_resolve_priority_tag_skips_unusable_tags(manager):
|
||||
assert manager.resolve_priority_tag_for_model([" portrait "], "lora") == "portrait"
|
||||
|
||||
|
||||
def test_resolve_priority_tag_skips_civitai_meta_tags(manager):
|
||||
"""Civitai's structural labels are not content, so they cannot be folders."""
|
||||
assert manager.resolve_priority_tag_for_model(["base model"], "lora") == ""
|
||||
assert (
|
||||
manager.resolve_priority_tag_for_model(["Base Model"], "lora") == ""
|
||||
), "the meta tag check must be case-insensitive"
|
||||
assert manager.resolve_priority_tag_for_model(["base model", " "], "lora") == ""
|
||||
# A real tag after the label is still used.
|
||||
assert (
|
||||
manager.resolve_priority_tag_for_model(["base model", "portrait"], "lora")
|
||||
== "portrait"
|
||||
)
|
||||
|
||||
|
||||
def test_resolve_priority_tag_meta_tag_can_be_opted_into(manager):
|
||||
"""An explicit priority entry still wins over the meta tag exclusion."""
|
||||
manager.settings["priority_tags"] = {"lora": "base model"}
|
||||
|
||||
assert (
|
||||
manager.resolve_priority_tag_for_model(["base model", "portrait"], "lora")
|
||||
== "base model"
|
||||
)
|
||||
|
||||
|
||||
def test_resolve_priority_tag_real_1119_tag_list(manager):
|
||||
"""End to end for the reported model: both of its tags are unusable."""
|
||||
assert (
|
||||
manager.resolve_priority_tag_for_model(
|
||||
[KEYWORD_DUMP_TAG, "base model"], "lora"
|
||||
)
|
||||
== ""
|
||||
)
|
||||
|
||||
|
||||
def test_auto_set_default_roots(manager):
|
||||
# Clear any previously auto-set values to test fresh behavior
|
||||
manager.settings["default_lora_root"] = ""
|
||||
|
||||
@@ -177,6 +177,20 @@ def test_calculate_relative_path_uses_next_usable_tag(isolated_settings):
|
||||
assert calculate_relative_path_for_model(model_data, "lora") == "Krea 2/portrait"
|
||||
|
||||
|
||||
def test_calculate_relative_path_ignores_civitai_meta_tag(isolated_settings):
|
||||
"""Civitai's "base model" label is not content, so it is not a folder."""
|
||||
model_data = {"base_model": "Krea 2", "tags": ["base model"]}
|
||||
|
||||
assert calculate_relative_path_for_model(model_data, "lora") == "Krea 2/no tags"
|
||||
|
||||
|
||||
def test_calculate_relative_path_ignores_full_1119_tag_list(isolated_settings):
|
||||
"""The reported model carries only a keyword dump and the meta label."""
|
||||
model_data = {"base_model": "Krea 2", "tags": [KEYWORD_DUMP_TAG, "base model"]}
|
||||
|
||||
assert calculate_relative_path_for_model(model_data, "lora") == "Krea 2/no tags"
|
||||
|
||||
|
||||
def test_calculate_relative_path_sanitizes_tag_segment(isolated_settings):
|
||||
"""A tag with path separators must not create nested folders."""
|
||||
model_data = {"base_model": "SDXL", "tags": ["a/b:c"]}
|
||||
|
||||
Reference in New Issue
Block a user