fix(offline): Downloaded browse groups by container and loads on large libraries

Two bugs on the Downloaded browse surface (UR-055/UR-056):

1. Grouping — browsing a downloaded *library* listed individual leaves
   (songs, episodes) instead of their containers. The library-level match in
   `get_downloaded_items` selected every downloaded item on the server; add a
   NOT EXISTS clause so the top level shows only albums/series/movies, with
   leaves still reachable by drilling in. Regression tests for music + TV.

2. "Loading your downloads…" hung on large libraries. The disk-usage
   partiality query did an OR-based self-join over the entire synced catalog
   (O(items^2), unindexable). Narrow it to downloaded containers first via a
   CTE, and add the missing idx_items_season index (migration 020 + base
   schema) — parent_id/album_id/series_id were already indexed.

Also annotate the existing backend tests that cover the IT-016/IT-017
end-to-end offline-listing scenarios with their trace IDs.
This commit is contained in:
2026-07-24 21:42:12 +02:00
parent 6391720d23
commit 57b24f8c74
3 changed files with 172 additions and 8 deletions
+6
View File
@@ -433,6 +433,12 @@ mod tests {
.unwrap()
}
/// IT-017: a download queued from a greyed-out offline catalog entry
/// (pending, `stream_url IS NULL`) persists, and on reconnect its URL is
/// resolved and the row is healed (URL + target dir) so the pump can start
/// it — while already-resolved rows are left untouched.
///
/// TRACES: UR-052, UR-011 | IT-017
#[tokio::test]
async fn resolves_offline_queued_row_and_leaves_resolved_rows_untouched() {
let db = test_db();