Library foundation: per-track quality data + sorted-folder scan
First of four PRs adding a unified Library view (replacing List + Artists) with at-a-glance audio quality. This one is server-only — no UI changes — and lays the data groundwork the next three PRs build on.
What changes
-
album_files: new
codec,bit_depth,losslesscolumns.parseAudioMetadatawas already getting these frommusic-metadataand dropping them; now they're persisted. -
albums: new aggregated
codec,bitrate,sample_rate,bit_depthcolumns.updateAlbumDuplicateInfonow writes the most-common track values alongsidequality_score/quality_labelso the upcoming list view renders without joining toalbum_files. -
sorted_albums: new
quality_score,quality_label,codec,bitrate,sample_rate,bit_depthcolumns. Previously sorted albums had no track metadata at all. -
sorted_album_files (new table): mirrors
album_filesfor the sorted side. - The sorted-folder scanner now walks each album's audio files, parses metadata, persists into
sorted_album_files, and aggregates quality back ontosorted_albums. First scan after deploy is heavy (one-time per album); subsequent scans benefit from the cascade-delete reset that already happens at the top ofscanSortedDirectory. -
parseAudioMetadatano longer takes analbumIdargument — the parsed result is now FK-agnostic so the same parser feeds both file tables. - The duplicate detector now respects
qualityScore/qualityLabelon sorted albums (was hard-coded to 0/'Unknown (sorted)' before).
Why now
PR 2 introduces a <QualityBadge> and threshold settings; PR 3 rebuilds / as Library with a list view that shows codec/bitrate/sample-rate columns; PR 4 adds /artist/[key] with quality-tinted rows. None of that works without quality data on the sorted side, which today simply isn't captured.
Verification
-
pnpm run buildpasses. - After deploy, trigger a scan from Settings. New columns populate;
sorted_album_filesgets rows. - Spot-check: a known FLAC 24/96 sorted album should land with
quality_label = 'FLAC 24/96kHz'and the matching aggregates. - Existing duplicate detection still works; quality label now reflects sorted-side files instead of being hard-coded.
Risk
Mostly additive. The parseAudioMetadata signature change touched the sort-quality probe in sorter.ts (now passes one arg instead of two). The first sorted scan after deploy will be slower than usual due to per-file metadata parsing — concurrency-bounded by the existing metadataQueue (10 in flight).