feat(metadata): resolve AutoV3 at download time without waiting for backfill

- Read AutoV3 directly from the downloaded file's own file_info hashes
  (no SHA256 cross-matching against version_info.files, so the value is
  captured even when the API omits SHA256)
- Extract normalize_autov3() validation helper shared with the
  sha256-matching autov3_from_civitai_files path
- Fall back to the embedded safetensors header hash at download
  completion; mark '' (checked-unavailable) so the startup backfill
  query (autov3 IS NULL) never revisits the row
- Clear archive-level AutoV3 for zip-extracted models so per-file
  header resolution applies to every extracted model
This commit is contained in:
Will Miao
2026-08-08 15:20:43 +08:00
parent 97b9b1f62b
commit 6fcdeb799d
6 changed files with 197 additions and 18 deletions

View File

@@ -100,6 +100,7 @@ async def test_execute_download_uses_rewritten_civitai_preview(monkeypatch, tmp_
self.sha256 = "sha256"
self.file_name = path.stem
self.preview_url = None
self.autov3 = None
self.preview_nsfw_level = None
def generate_unique_filename(self, *_args, **_kwargs):
@@ -204,6 +205,7 @@ async def test_execute_download_respects_blur_setting(monkeypatch, tmp_path):
self.sha256 = "sha256"
self.file_name = path.stem
self.preview_url = None
self.autov3 = None
self.preview_nsfw_level = None
def generate_unique_filename(self, *_args, **_kwargs):
@@ -325,6 +327,7 @@ async def test_execute_download_uses_auth_for_red_civitai_downloads(monkeypatch,
self.sha256 = "sha256"
self.file_name = path.stem
self.preview_url = None
self.autov3 = None
self.preview_nsfw_level = None
def generate_unique_filename(self, *_args, **_kwargs):