diff --git a/src-tauri/src/library/database.rs b/src-tauri/src/library/database.rs index 073cbb28e..89415e640 100644 --- a/src-tauri/src/library/database.rs +++ b/src-tauri/src/library/database.rs @@ -1039,7 +1039,8 @@ impl LibraryDatabase { MAX(format) as format, MAX(bit_depth) as bit_depth, MAX(sample_rate) as sample_rate, - MAX(group_key) as directory_path + MAX(group_key) as directory_path, + MAX(source) as source FROM ( SELECT COALESCE(album_group_key, album || '|' || COALESCE(album_artist, artist)) as group_key, @@ -1051,7 +1052,8 @@ impl LibraryDatabase { duration_secs, format, bit_depth, - sample_rate + sample_rate, + COALESCE(source, 'user') as source FROM local_tracks WHERE 1=1 {} {} ) @@ -1078,7 +1080,8 @@ impl LibraryDatabase { MAX(format) as format, MAX(bit_depth) as bit_depth, MAX(sample_rate) as sample_rate, - MAX(group_key) as directory_path + MAX(group_key) as directory_path, + MAX(source) as source FROM ( SELECT COALESCE(album_group_key, album || '|' || COALESCE(album_artist, artist)) as group_key, @@ -1090,7 +1093,8 @@ impl LibraryDatabase { duration_secs, format, bit_depth, - sample_rate + sample_rate, + COALESCE(source, 'user') as source FROM local_tracks WHERE 1=1 {} {} ) @@ -1135,6 +1139,7 @@ impl LibraryDatabase { directory_path: row .get::<_, Option>(11)? .unwrap_or_else(|| group_key.clone()), + source: row.get::<_, Option>(12)?.unwrap_or_else(|| "user".to_string()), }) }) .map_err(|e| LibraryError::Database(e.to_string()))?; diff --git a/src-tauri/src/library/models.rs b/src-tauri/src/library/models.rs index 0fa7abc5f..37e4d58ca 100644 --- a/src-tauri/src/library/models.rs +++ b/src-tauri/src/library/models.rs @@ -136,6 +136,13 @@ pub struct LocalAlbum { pub bit_depth: Option, pub sample_rate: f64, // Changed from u32 to f64 for decimal precision pub directory_path: String, + /// Source of the album: "user" for local files, "qobuz_download" for offline cached + #[serde(default = "default_source")] + pub source: String, +} + +fn default_source() -> String { + "user".to_string() } /// An artist aggregated from local tracks diff --git a/src/lib/components/AlbumCard.svelte b/src/lib/components/AlbumCard.svelte index 167ef310c..f5ce0e694 100644 --- a/src/lib/components/AlbumCard.svelte +++ b/src/lib/components/AlbumCard.svelte @@ -1,6 +1,6 @@