Files
ComfyUI/tests-unit
Simon Pinfold e5aa56ef8b Rebuild stale asset records when the assets system is enabled
Alembic migrates the shape of the assets tables. Nothing migrated their
meaning, so a row could be structurally current and still hold values a
superseded rule computed, with no maintenance path that ever repaired it.

loader_path is the clearest case: the column was added to existing databases
with no backfill, and it is only ever written when a reference is first
created. The scan computes it for paths it has not seen before, so every
reference older than the column serves a null loader path forever -- while the
API tells clients to prefer loader_path over name.

A semantics version now records which generation of the derivation logic
produced a database's rows, tracked separately from the Alembic schema version
because the two move independently. Reset steps are numbered and applied in
order from the stored version, each stamped only once it finishes, so an
interrupted run resumes instead of half-applying.

The first step re-derives what a file's location implies -- loader_path, the
backend tags a path carries, and whether the file is there -- and leaves
everything else alone. It reads no file contents: verify_file_unchanged says
whether a row's recorded hash and size still describe the file, and a file that
has moved on is handed to the existing needs_verify path rather than re-read,
so an untouched model library costs one stat per file and no hashing. Manual
tags, user metadata, previews, deletions and job ids are never touched, nor are
references whose file is gone or whose path falls outside every root this
install currently knows about.

It runs at the start of a scan, before anything reads or extends those rows. A
database already at the current version costs one indexed row read.
2026-08-17 23:32:51 -07:00
..

Pytest Unit Tests

Install test dependencies

pip install -r tests-unit/requirements.txt

Run tests

pytest tests-unit/