mirror of
https://github.com/storytold/lightcraft.git
synced 2026-10-26 19:17:02 -06:00
stack_of, validate_stack and regular-album membership looked a photo up by scanning every stack or the album's list, so an "In a Stack" or "Album" smart album, or a query filtered to an album, cost photos x list length (2.7 s and 0.6-0.8 s at 100k photos). Derived indexes (never saved) answer them now: built on first use, kept current by the six ops that change stacks or album photos in apply_inner, so undo, failed-batch rollback and journal replay follow. A file with a photo in two stacks falls back to the scan. query() works out each sort key once (File Name was lower-cased twice per comparison) and tests `only` as a set; smart-album passes prepare the filter once; rules name flag, label and kind without formatting per photo. A property test checks the indexes against a scan through random op sequences, rollbacks, snapshots, replay, clones and undo. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>