Merge pull request #551 from willmiao/codex/refactor-model-metadata-saving-logic

fix: hydrate cached metadata before persisting updates
This commit is contained in:
pixelpaws
2025-10-10 08:56:12 +08:00
committed by GitHub
3 changed files with 65 additions and 11 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)}"
@@ -176,6 +181,7 @@ class MetadataSyncService:
metadata_provider = await self._get_default_provider()
civitai_metadata, error = await metadata_provider.get_model_by_hash(sha256)
if not civitai_metadata:
if error == "Model not found":
model_data["from_civitai"] = False