Index sorted albums immediately when a sort succeeds
Summary
Follow-up to PR #29: the new Artists view reads counts and the Sorted section from the sortedAlbums table, but executeSort only updated albums.status — sortedAlbums stayed stale until a full sorted-directory rescan. So after sorting an album from /artists, the pending count dropped (from albums.status) but the sorted count didn't increase and the newly-sorted album didn't appear in the Sorted section.
Fix: insert a sortedAlbums row as part of executeSort, right after the disk copy and status update. The row mirrors exactly what scanSortedDirectory would produce — same folder-name regex, same Various Artists handling for Soundtracks — so a subsequent full rescan produces an identical row with no drift. onConflictDoUpdate on folderPath handles the overwrite path cleanly.
With this, /artists's handleSorted (which already clears its cache and refetches) now sees correct counts and section contents immediately, with no button and no polling needed.
Test plan
-
pnpm run buildpasses -
Sort an album from /artists→ Unsorted section drops it, Sorted section shows it, counts update -
Sort an album from /(home) → navigate to/artists→ counts reflect the sort without a manual refresh -
Overwrite an existing sorted album (sort with overwriteExisting: trueto the same target path) →sortedAlbumsrow updates cleanly viaonConflictDoUpdate -
Sort a Soundtrack → row is inserted with artist: 'Various Artists'to matchscanSortedDirectory -
Run a full sorted-directory rescan afterwards → no drift, sortedAlbumsstays identical