Fix for offline mode
This commit is contained in:
@@ -201,6 +201,7 @@ mod tests {
|
||||
"thumbnails",
|
||||
"playlists",
|
||||
"playlist_items",
|
||||
"genres",
|
||||
];
|
||||
|
||||
for table in expected_tables {
|
||||
|
||||
@@ -23,6 +23,7 @@ pub const MIGRATIONS: &[(&str, &str)] = &[
|
||||
("016_autoplay_max_episodes", MIGRATION_016),
|
||||
("017_downloads_resume_url", MIGRATION_017),
|
||||
("018_items_is_folder", MIGRATION_018),
|
||||
("019_genres_cache", MIGRATION_019),
|
||||
];
|
||||
|
||||
/// Initial schema migration
|
||||
@@ -693,3 +694,23 @@ ALTER TABLE items ADD COLUMN is_folder INTEGER DEFAULT 0;
|
||||
-- Force re-fetch of all cached items so is_folder is populated from the server.
|
||||
UPDATE items SET synced_at = NULL;
|
||||
"#;
|
||||
|
||||
/// Migration to cache the full server genre catalog. Previously genres were
|
||||
/// derived on the fly from cached albums, which meant offline (and the hybrid
|
||||
/// cache-first race) only ever saw genres for the handful of locally-cached
|
||||
/// albums — collapsing the variety on the music/TV/movie landing pages. This
|
||||
/// table stores the complete genre list per library so offline has the real
|
||||
/// catalog and cache-first routing returns the right thing.
|
||||
const MIGRATION_019: &str = r#"
|
||||
CREATE TABLE IF NOT EXISTS genres (
|
||||
id TEXT NOT NULL,
|
||||
server_id TEXT NOT NULL,
|
||||
library_id TEXT,
|
||||
name TEXT NOT NULL,
|
||||
album_count INTEGER,
|
||||
synced_at TEXT DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (server_id, library_id, name)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_genres_scope ON genres(server_id, library_id);
|
||||
"#;
|
||||
|
||||
Reference in New Issue
Block a user