fix: skip redundant hydration in metadata sync service

This commit is contained in:
pixelpaws
2025-10-10 08:49:54 +08:00
parent ef03a2a917
commit 8f5e134d3e
3 changed files with 15 additions and 5 deletions

View File

@@ -153,7 +153,12 @@ class MetadataSyncService:
model_data: Dict[str, Any],
update_cache_func: Callable[[str, str, Dict[str, Any]], Awaitable[bool]],
) -> tuple[bool, Optional[str]]:
"""Fetch metadata for a model and update both disk and cache state."""
"""Fetch metadata for a model and update both disk and cache state.
Callers should hydrate ``model_data`` via ``MetadataManager.hydrate_model_data``
before invoking this method so that the persisted payload retains all known
metadata fields.
"""
if not isinstance(model_data, dict):
error = f"Invalid model_data type: {type(model_data)}"
@@ -177,8 +182,6 @@ class MetadataSyncService:
civitai_metadata, error = await metadata_provider.get_model_by_hash(sha256)
await self._metadata_manager.hydrate_model_data(model_data)
if not civitai_metadata:
if error == "Model not found":
model_data["from_civitai"] = False