refactor(backend): retire unused native bridge entry points

This commit is contained in:
zarzet committed 2026-09-30 21:47:15 +07:00
1 parent b8e3a4c166
commit fe88048db2
45 files changed
+20 -1832

No files matched your search

@@ -391,13 +391,6 @@ impl Backend {
Ok(output.display())
}
pub fn clear_cover_memory_cache(&self) -> Result<(), String> {
let _operation = self.enter()?;
self.cover.clear();
spotiflac_core::cover::clear_library_thumbnail_cache();
Ok(())
}
pub fn download_cover_to_file_sized(
&self,
url: &str,
@@ -60,17 +60,6 @@ impl Backend {
.unwrap_or_else(|error| native_error_response(&error).to_string()))
}
pub fn download_with_extensions_json(
&self,
raw: &str,
check: &Check<'_>,
) -> Result<String, String> {
let _operation = self.enter()?;
let request =
DownloadRequest::parse(raw).map_err(|error| format!("invalid request: {error}"))?;
self.download_request(request, check)
}
fn download_request(
&self,
mut request: DownloadRequest,
@@ -75,21 +75,6 @@ impl Backend {
Ok(())
}
pub fn scan_library_folder(&self, folder: &str, check: Check<'_>) -> Result<Value, String> {
let mut tracks = Vec::new();
self.scan_library(
folder,
None,
true,
&mut |value| {
tracks.push(value);
Ok(())
},
check,
)?;
Ok(tracks.into())
}
pub fn scan_library_folder_incremental(
&self,
folder: &str,
@@ -118,11 +118,6 @@ impl Backend {
Ok(response)
}
pub fn get_lyrics_providers_json(&self) -> Result<String, String> {
let _operation = self.enter()?;
serde_json::to_string(&self.lyrics.providers()).map_err(|error| error.to_string())
}
pub fn set_lyrics_providers_json(&self, raw: &str) -> Result<(), String> {
let _operation = self.enter()?;
let providers = config::decode_providers(raw).map_err(|error| error.to_string())?;
@@ -136,11 +131,6 @@ impl Backend {
serde_json::to_string(&config::available_providers()).map_err(|error| error.to_string())
}
pub fn get_lyrics_fetch_options_json(&self) -> Result<String, String> {
let _operation = self.enter()?;
serde_json::to_string(&self.lyrics.options()).map_err(|error| error.to_string())
}
pub fn set_lyrics_fetch_options_json(&self, raw: &str) -> Result<(), String> {
let _operation = self.enter()?;
let _settings = self.lyrics_settings.lock().expect("lyrics settings lock");
@@ -2,7 +2,7 @@ use super::Backend;
use serde::Serialize;
use serde_json::{Value, json};
use spotiflac_core::metadata::TrackMetadata;
use spotiflac_providers::deezer::{self, MetadataLookup};
use spotiflac_providers::deezer::MetadataLookup;
use spotiflac_providers::musicbrainz::MusicBrainzOptions;
use spotiflac_providers::resolver::{Check, ResolverError, ResolverOptions};
use std::time::{Duration, Instant};
@@ -97,13 +97,6 @@ impl Backend {
.map_err(|error| error.to_string())
}
pub fn get_song_link_region(&self) -> Result<String, String> {
let _operation = self.enter()?;
self.availability
.region()
.map_err(|error| error.to_string())
}
// The retired Settings track-ID cache is distinct from catalog caches.
pub fn get_track_cache_size(&self) -> Result<u64, String> {
let _operation = self.enter()?;
@@ -115,11 +108,6 @@ impl Backend {
Ok(())
}
pub fn parse_deezer_url(&self, url: &str) -> Result<(String, String), String> {
let _operation = self.enter()?;
deezer::parse_url(url).map_err(|error| error.to_string())
}
pub fn search_deezer(
&self,
query: &str,
@@ -137,15 +125,6 @@ impl Backend {
})
}
pub fn get_deezer_metadata(
&self,
kind: &str,
id: &str,
check: &Check<'_>,
) -> Result<String, String> {
self.metadata_operation(30, check, |check| self.deezer_metadata(kind, id, check))
}
pub(super) fn deezer_metadata(
&self,
kind: &str,
@@ -175,10 +154,6 @@ impl Backend {
})
}
pub fn search_deezer_by_isrc(&self, isrc: &str, check: &Check<'_>) -> Result<String, String> {
self.search_deezer_by_isrc_for_item_id(isrc, "", check)
}
pub fn search_deezer_by_isrc_for_item_id(
&self,
isrc: &str,
@@ -246,69 +221,6 @@ impl Backend {
})
}
pub fn check_track_availability_json(
&self,
id: &str,
isrc: &str,
check: &Check<'_>,
) -> Result<String, String> {
self.metadata_operation(30, check, |check| {
encode(&self.availability.check_track(id, isrc, check)?)
})
}
pub fn check_album_availability_json(
&self,
id: &str,
check: &Check<'_>,
) -> Result<String, String> {
self.metadata_operation(30, check, |check| {
encode(&self.availability.check_album(id, check)?)
})
}
pub fn check_availability_from_deezer_json(
&self,
id: &str,
check: &Check<'_>,
) -> Result<String, String> {
self.metadata_operation(30, check, |check| {
encode(&self.availability.check_from_deezer(id, check)?)
})
}
pub fn check_availability_by_platform_json(
&self,
platform: &str,
kind: &str,
id: &str,
check: &Check<'_>,
) -> Result<String, String> {
self.metadata_operation(30, check, |check| {
encode(
&self
.availability
.check_by_platform(platform, kind, id, check)?,
)
})
}
pub fn check_availability_from_url_json(
&self,
url: &str,
check: &Check<'_>,
) -> Result<String, String> {
self.metadata_operation(30, check, |check| {
encode(&self.availability.check_from_url(url, check)?)
})
}
pub fn get_streaming_urls_json(&self, id: &str, check: &Check<'_>) -> Result<String, String> {
self.metadata_operation(30, check, |check| {
encode(&self.availability.streaming_urls(id, check)?)
})
}
pub fn get_deezer_id_from_spotify(
&self,
id: &str,
@@ -316,66 +228,6 @@ impl Backend {
) -> Result<String, String> {
self.metadata_operation(30, check, |check| self.deezer_id_from_spotify(id, check))
}
pub fn get_deezer_album_id_from_spotify(
&self,
id: &str,
check: &Check<'_>,
) -> Result<String, String> {
self.metadata_operation(30, check, |check| {
self.availability.deezer_album_id(id, check)
})
}
pub fn get_youtube_url_from_spotify(
&self,
id: &str,
check: &Check<'_>,
) -> Result<String, String> {
self.metadata_operation(30, check, |check| {
self.availability.youtube_url_from_spotify(id, check)
})
}
pub fn get_spotify_id_from_deezer_track(
&self,
id: &str,
check: &Check<'_>,
) -> Result<String, String> {
self.metadata_operation(30, check, |check| {
self.availability.platform_from_deezer(id, "spotify", check)
})
}
pub fn get_tidal_url_from_deezer_track(
&self,
id: &str,
check: &Check<'_>,
) -> Result<String, String> {
self.metadata_operation(30, check, |check| {
self.availability.platform_from_deezer(id, "tidal", check)
})
}
pub fn get_amazon_url_from_deezer_track(
&self,
id: &str,
check: &Check<'_>,
) -> Result<String, String> {
self.metadata_operation(30, check, |check| {
self.availability.platform_from_deezer(id, "amazon", check)
})
}
pub fn get_youtube_url_from_deezer_track(
&self,
id: &str,
check: &Check<'_>,
) -> Result<String, String> {
self.metadata_operation(30, check, |check| {
self.availability.platform_from_deezer(id, "youtube", check)
})
}
}
#[cfg(test)]
@@ -10,13 +10,6 @@ use std::time::Duration;
mod value_tests;
impl Backend {
pub fn enrich_track_json(&self, id: &str, track_json: &str) -> Result<String, String> {
let _operation = self.enter()?;
self.manager
.enrich_track_export(id, track_json)
.map_err(|error| error.to_string())
}
pub fn handle_url_json(&self, url: &str) -> Result<String, String> {
let _operation = self.enter()?;
let id = self
@@ -11,24 +11,6 @@ use std::io::Write;
use std::sync::Mutex;
impl Backend {
/// Resolve proposed tags without reading audio, downloading covers or writing files.
pub fn preview_reenrich_file(
&self,
request_json: &str,
check: &Check<'_>,
) -> Result<String, String> {
let _operation = self.enter()?;
let check = || {
self.check()?;
check()
};
check()?;
let request = self.resolve_reenrich_request(request_json, &check)?;
serde_json::to_string(&json!({"method":"preview","success":true,
"enriched_metadata":request.result_metadata()}))
.map_err(|error| error.to_string())
}
/// Execute FLAC enrichment or return the existing native FFmpeg plan.
/// Returned cover files belong to the caller, which removes them after use.
pub fn reenrich_file(&self, request_json: &str, check: &Check<'_>) -> Result<String, String> {