mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-22 15:25:46 +00:00
fix(analysis): native library backfill coordinator for advanced strategy (#881)
* feat(analysis): native library backfill coordinator for advanced strategy Move advanced analytics scheduling from the webview loop into a Rust background worker (configure + spawn_blocking batch/enqueue), matching cover backfill. Scan hash+BPM gap tracks instead of the full library; suppress low-priority analysis UI events; limit loudness refresh IPC to the playback window. * fix(analysis): flat backfill configure IPC and restore probe track-perf Use flattened Tauri args like cover backfill so release/prod invoke works; keep emitting analysis:track-perf for library low-priority work so Performance Probe tpm/last-track stats update while waveform/enrichment UI events stay suppressed. * chore(analysis): fix clippy and drop duplicate TS backfill policy Allow too_many_arguments on library_analysis_backfill_configure for CI; remove unused frontend batch API and TS watermark helpers now owned in Rust; clarify analysis_emits_ui_events comment for low-priority track-perf. * docs: CHANGELOG and credits for PR #881 native analysis backfill
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
//! Library analysis backfill — native coordinator (advanced analytics strategy).
|
||||
|
||||
mod worker;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use tauri::{AppHandle, Manager};
|
||||
use worker::{
|
||||
spawn_coordinator, setup_library_sync_idle_listener, LibraryAnalysisBackfillSession,
|
||||
LibraryAnalysisBackfillWorker,
|
||||
};
|
||||
|
||||
|
||||
pub fn init_library_analysis_backfill(app: &AppHandle) -> Result<(), String> {
|
||||
let worker = Arc::new(LibraryAnalysisBackfillWorker::new());
|
||||
app.manage(worker.clone());
|
||||
setup_library_sync_idle_listener(app);
|
||||
spawn_coordinator(app, worker);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[allow(clippy::too_many_arguments)] // Tauri command surface — args map 1:1 to the JS call (like cover configure + workers).
|
||||
pub async fn library_analysis_backfill_configure(
|
||||
app: AppHandle,
|
||||
enabled: bool,
|
||||
server_index_key: String,
|
||||
library_server_id: String,
|
||||
server_url: String,
|
||||
username: String,
|
||||
password: String,
|
||||
workers: u32,
|
||||
) -> Result<(), String> {
|
||||
let worker = app
|
||||
.try_state::<Arc<LibraryAnalysisBackfillWorker>>()
|
||||
.ok_or_else(|| "library analysis backfill worker not initialized".to_string())?;
|
||||
|
||||
let session = if enabled
|
||||
&& !server_index_key.is_empty()
|
||||
&& !library_server_id.is_empty()
|
||||
&& !server_url.is_empty()
|
||||
{
|
||||
Some(LibraryAnalysisBackfillSession {
|
||||
server_index_key,
|
||||
library_server_id,
|
||||
server_url,
|
||||
username,
|
||||
password,
|
||||
workers: workers.max(1),
|
||||
})
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
worker
|
||||
.set_session(enabled && session.is_some(), session)
|
||||
.await;
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user