soulsync/database
Broque Thomas 751b19c7b1 Preserve api_track_count across Plex ratingKey rekeys
Reported by kettui on PR #374 review:

> api_track_count is not copied during the ratingKey migration, so
> the cache disappears when an album row is rekeyed. Add it to
> enrichment_cols or the next completeness scan will fall back to
> live API lookups again.

When Plex changes an album's ratingKey (after a library rescan), the
sync code rekeys the album row by inserting a new row at the new ID
and copying enrichment columns from the old row. The list of
columns to copy did not include `api_track_count`, so the cached
authoritative track count was lost on rekey — and the next completeness
scan would hit the fallback path that calls back out to the
metadata source's API. Defeats the cache.

Added `api_track_count` to the album-level `enrichment_cols` at
`music_database.py:4724`. The artist-level lists at lines 4238 and
4554 don't need updating — those are for artist rekeys and don't
carry album-scoped fields.

No new test — existing migration code has no test infrastructure
and writing a Plex-mocked one is larger than this fix. Cin will say
if he wants test coverage in his next review pass.

Credit: kettui — PR #374 review comment that flagged the missing
column in the rekey allowlist.
2026-04-25 08:31:30 -07:00
..
__init__.py basic db structure 2025-08-05 22:43:04 -07:00
music_database.py Preserve api_track_count across Plex ratingKey rekeys 2026-04-25 08:31:30 -07:00