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
This commit is contained in:
2 files changed
+19
-51
No files matched your search
@@ -550,9 +550,8 @@ pub async fn v2_library_update_folder_settings(
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn v2_discogs_has_credentials() -> Result<bool, RuntimeError> {
|
||||
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<String>,
|
||||
) -> Result<Vec<crate::discogs::DiscogsImageOption>, 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<String, RuntimeError> {
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -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<bool, String> {
|
||||
// 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<String>,
|
||||
) -> Result<Vec<crate::discogs::DiscogsImageOption>, 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<String, String> {
|
||||
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(
|
||||
|
||||
Reference in new issue
Block a user