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

@@ -1,5 +1,5 @@
use super::{EnvironmentError, ExtensionEnvironment};
use spotiflac_core::isrc::{IndexCache, IndexFiles, NativeFiles, parse_tracks};
use spotiflac_core::isrc::{IndexCache, NativeFiles};
use std::sync::atomic::Ordering;
type Check<'a> = &'a (dyn Fn() -> Result<(), String> + Sync);
@@ -27,27 +27,6 @@ impl ExtensionEnvironment {
/// Trusted native entry points share the SDK's index, while JavaScript uses
/// a scoped IndexFiles adapter and revalidates native directory grants.
pub fn prebuild_isrc_index(
&self,
directory: &str,
check: Check<'_>,
) -> Result<(), EnvironmentError> {
self.with_index(check, |cache, files, check| {
cache.prebuild(directory, files, check)
})
}
pub fn check_isrc_exists(
&self,
directory: &str,
isrc: &str,
check: Check<'_>,
) -> Result<String, EnvironmentError> {
self.with_index(check, |cache, files, check| {
cache.check(directory, isrc, files, check)
})
}
pub fn add_to_isrc_index(
&self,
directory: &str,
@@ -60,33 +39,9 @@ impl ExtensionEnvironment {
})
}
pub fn check_files_exist_parallel(
&self,
directory: &str,
tracks_json: &str,
check: Check<'_>,
) -> Result<String, EnvironmentError> {
self.with_index(check, |cache, files, check| {
if tracks_json.len() > 8 * 1024 * 1024 {
return Err("tracks JSON exceeds 8 MiB limit".into());
}
let tracks = parse_tracks(tracks_json)?;
let results = cache.check_batch(directory, &tracks, files, check)?;
serde_json::to_string(&results).map_err(|error| error.to_string())
})
}
pub fn invalidate_isrc_cache(&self, directory: &str) -> Result<(), EnvironmentError> {
let _operation = self.enter()?;
self.isrc.invalidate(directory);
Ok(())
}
pub fn check_file_exists(&self, path: &str) -> Result<bool, EnvironmentError> {
let _operation = self.enter()?;
NativeFiles
.stat(path)
.map(|stamp| stamp.is_some_and(|stamp| !stamp.directory && stamp.size > 0))
.map_err(EnvironmentError::Index)
}
}