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:
Will Miao
2026-09-23 13:33:59 +08:00
parent 0ada32d0c7
commit 74736f7560
7 changed files with 93 additions and 7 deletions
+15 -3
View File
@@ -273,6 +273,16 @@ CIVITAI_MODEL_TAGS = [
"action",
]
# Civitai tags that describe the listing rather than the model's content.
# Uploaders can also set these by hand, so they must not be picked as an
# automatic folder name; a user who wants one can still name it explicitly in
# their priority tag list.
CIVITAI_META_TAGS = frozenset(
{
"base model",
}
)
# Default priority tag configuration strings for each model type
DEFAULT_PRIORITY_TAG_CONFIG = {
"lora": ", ".join(CIVITAI_MODEL_TAGS),
@@ -295,9 +305,11 @@ DEFAULT_DOWNLOAD_PATH_TEMPLATES: Dict[str, str] = {
# Length guards for template placeholders that end up in file and folder names.
# Windows enforces MAX_PATH (260 characters) on the full path and 255 on a
# single path component, and a model folder also has to leave room for the
# model file, its ".civitai.info"/".json" sidecars and preview images. Values
# stay well below those limits so the surrounding files still fit.
# single path component. A model folder also holds the model file, the
# ".metadata.json" sidecar written by LoRA Manager, preview images and the
# metadata files other tools drop next to the model (for example
# ".civitai.info", which LoRA Manager only reads), so names stay well below
# those limits.
#
# Tags get a much tighter budget than other names: some CivitAI uploaders dump
# their whole keyword list into a single tag (see issue #1119), and such a tag
+17 -1
View File
@@ -5,7 +5,7 @@ from __future__ import annotations
from dataclasses import dataclass
from typing import Dict, Iterable, List, Optional, Sequence, Set
from .constants import MAX_PATH_TAG_LENGTH
from .constants import CIVITAI_META_TAGS, MAX_PATH_TAG_LENGTH
@dataclass(frozen=True)
@@ -128,3 +128,19 @@ def is_usable_path_tag(tag: object) -> bool:
return False
return len(candidate) <= MAX_PATH_TAG_LENGTH
def is_civitai_meta_tag(tag: object) -> bool:
"""Return True for Civitai labels that describe the listing, not content.
Civitai attaches structural tags such as "base model" to the same list as
real content tags. They carry no organisational meaning, so the automatic
fallback must not turn one into a folder name. A user who does want such a
folder can still put the label in their priority tag list, because explicit
priority matches bypass this check.
"""
if not isinstance(tag, str):
return False
return tag.strip().casefold() in CIVITAI_META_TAGS