From 40b8ec90a0acceefa86aaa865799e96ef940616b Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Sun, 26 Apr 2026 18:11:58 -0600 Subject: [PATCH] refactor(v2): inline discogs delegates and delete legacy discogs commands Inlines the bodies of `discogs_has_credentials`, `discogs_search_artwork`, and `discogs_download_artwork` from crate::library::commands::* directly into commands_v2/legacy_compat.rs. The discogs delegates were single-line bodies (or trivial proxy logic); DiscogsClient and library::get_artwork_cache_dir are reused as-is. The String error type from the underlying DiscogsClient methods is mapped to RuntimeError::Internal at the v2 boundary, matching the existing v2 contracts. Deletes the legacy #[tauri::command] definitions from library/commands.rs. No frontend invoke changes required. Step 6 of the legacy cleanup plan, group B (discogs). cc --- src-tauri/src/commands_v2/legacy_compat.rs | 24 ++++++++--- src-tauri/src/library/commands.rs | 46 ---------------------- 2 files changed, 19 insertions(+), 51 deletions(-) diff --git a/src-tauri/src/commands_v2/legacy_compat.rs b/src-tauri/src/commands_v2/legacy_compat.rs index 72bc980fc..e00543307 100644 --- a/src-tauri/src/commands_v2/legacy_compat.rs +++ b/src-tauri/src/commands_v2/legacy_compat.rs @@ -550,9 +550,8 @@ pub async fn v2_library_update_folder_settings( #[tauri::command] pub async fn v2_discogs_has_credentials() -> Result { - crate::library::commands::discogs_has_credentials() - .await - .map_err(RuntimeError::Internal) + // Proxy always provides credentials. + Ok(true) } #[tauri::command] @@ -562,7 +561,16 @@ pub async fn v2_discogs_search_artwork( album: String, catalogNumber: Option, ) -> Result, RuntimeError> { - crate::library::commands::discogs_search_artwork(artist, album, catalogNumber) + log::info!( + "Command: v2_discogs_search_artwork {} - {} (catalog: {:?})", + artist, + album, + catalogNumber + ); + + let client = crate::discogs::DiscogsClient::new(); + client + .search_artwork_options(&artist, &album, catalogNumber.as_deref()) .await .map_err(RuntimeError::Internal) } @@ -574,7 +582,13 @@ pub async fn v2_discogs_download_artwork( artist: String, album: String, ) -> Result { - crate::library::commands::discogs_download_artwork(imageUrl, artist, album) + log::info!("Command: v2_discogs_download_artwork from {}", imageUrl); + + let cache_dir = crate::library::get_artwork_cache_dir(); + let client = crate::discogs::DiscogsClient::new(); + + client + .download_artwork_from_url(&imageUrl, &cache_dir, &artist, &album) .await .map_err(RuntimeError::Internal) } diff --git a/src-tauri/src/library/commands.rs b/src-tauri/src/library/commands.rs index c83442d55..732f7336e 100644 --- a/src-tauri/src/library/commands.rs +++ b/src-tauri/src/library/commands.rs @@ -1868,13 +1868,6 @@ pub async fn playlist_clear_custom_order( // === Discogs Artwork === -/// Check if Discogs credentials are configured (proxy handles credentials) -#[tauri::command] -pub async fn discogs_has_credentials() -> Result { - // Proxy always provides credentials - Ok(true) -} - /// Fetch missing artwork from Discogs for albums without artwork /// Returns number of albums updated #[tauri::command] @@ -2937,45 +2930,6 @@ pub async fn playlist_get_offline_available( Ok(playlists.iter().map(|p| p.qobuz_playlist_id).collect()) } -// === Discogs Artwork === - -/// Search Discogs for artwork options -#[tauri::command] -pub async fn discogs_search_artwork( - artist: String, - album: String, - catalog_number: Option, -) -> Result, String> { - log::info!( - "Command: discogs_search_artwork {} - {} (catalog: {:?})", - artist, - album, - catalog_number - ); - - let client = DiscogsClient::new(); - client - .search_artwork_options(&artist, &album, catalog_number.as_deref()) - .await -} - -/// Download and save Discogs artwork -#[tauri::command] -pub async fn discogs_download_artwork( - image_url: String, - artist: String, - album: String, -) -> Result { - log::info!("Command: discogs_download_artwork from {}", image_url); - - let cache_dir = get_artwork_cache_dir(); - let client = DiscogsClient::new(); - - client - .download_artwork_from_url(&image_url, &cache_dir, &artist, &album) - .await -} - /// Get multiple tracks by their IDs #[tauri::command] pub async fn library_get_tracks_by_ids(