feat(metadata): prevent overwriting high-quality Civitai API metadata with archive data. See #764

- Update `is_civitai_api_metadata` to exclude both "archive_db" and "civarchive" sources
- Skip Civitai metadata updates when existing metadata is higher quality than incoming archive data
- Add test to verify API metadata is preserved when CivArchive provides lower-quality data
This commit is contained in:
Will Miao
2026-01-09 19:47:32 +08:00
parent f2e12c0fd3
commit f842ea990e
2 changed files with 56 additions and 3 deletions

View File

@@ -76,7 +76,7 @@ class MetadataSyncService:
files = meta.get("files")
images = meta.get("images")
source = meta.get("source")
return bool(files) and bool(images) and source != "archive_db"
return bool(files) and bool(images) and source not in ("archive_db", "civarchive")
async def update_model_metadata(
self,
@@ -90,11 +90,11 @@ class MetadataSyncService:
existing_civitai = local_metadata.get("civitai") or {}
if (
civitai_metadata.get("source") == "archive_db"
not self.is_civitai_api_metadata(civitai_metadata)
and self.is_civitai_api_metadata(existing_civitai)
):
logger.info(
"Skip civitai update for %s (%s)",
"Skip civitai update for %s (%s) - existing metadata is higher quality",
local_metadata.get("model_name", ""),
existing_civitai.get("name", ""),
)