use axum::{Json, extract::State}; use crate::{ dto::{ScanJobResponse, ScanRequest, ScanStatusResponse}, error::ApiError, state::AppState, }; /// Trigger a scan as a background job. Returns the job ID immediately. pub async fn trigger_scan( State(state): State, Json(req): Json, ) -> Result, ApiError> { let kind = pinakes_core::jobs::JobKind::Scan { path: req.path }; let job_id = state.job_queue.submit(kind).await; Ok(Json(ScanJobResponse { job_id: job_id.to_string(), })) } pub async fn scan_status( State(state): State, ) -> Json { let snapshot = state.scan_progress.snapshot(); let error_count = snapshot.errors.len(); Json(ScanStatusResponse { scanning: snapshot.scanning, files_found: snapshot.files_found, files_processed: snapshot.files_processed, error_count, errors: snapshot.errors, }) }