diff --git a/apps/indexer/src/main.rs b/apps/indexer/src/main.rs index 7c2bea1..f697245 100644 --- a/apps/indexer/src/main.rs +++ b/apps/indexer/src/main.rs @@ -445,12 +445,15 @@ async fn process_job(state: &AppState, job_id: Uuid, target_library_id: Option {} Err(err) => { stats.errors += 1; @@ -461,9 +464,10 @@ async fn process_job(state: &AppState, job_id: Uuid, target_library_id: Option anyhow::Result<()> { @@ -515,7 +520,7 @@ async fn scan_library( } let mut seen: HashMap = HashMap::new(); - let mut processed_count = 0i32; + let mut library_processed_count = 0i32; for entry in WalkDir::new(root).into_iter().filter_map(Result::ok) { if !entry.file_type().is_file() { @@ -528,7 +533,8 @@ async fn scan_library( }; stats.scanned_files += 1; - processed_count += 1; + library_processed_count += 1; + *total_processed_count += 1; let abs_path_local = path.to_string_lossy().to_string(); // Convert local path to /libraries format for DB storage let abs_path = unmap_libraries_path(&abs_path_local); @@ -536,12 +542,12 @@ async fn scan_library( .map(|s| s.to_string_lossy().to_string()) .unwrap_or_else(|| abs_path.clone()); - info!("[SCAN] Job {} processing file {}/{}: {}", job_id, processed_count, total_files, file_name); + info!("[SCAN] Job {} processing file {}/{} (library: {}): {}", job_id, total_processed_count, total_files, library_processed_count, file_name); let start_time = std::time::Instant::now(); - // Update progress in DB + // Update progress in DB using the global processed count let progress_percent = if total_files > 0 { - ((processed_count as f64 / total_files as f64) * 100.0) as i32 + ((*total_processed_count as f64 / total_files as f64) * 100.0) as i32 } else { 0 }; @@ -552,7 +558,7 @@ async fn scan_library( ) .bind(job_id) .bind(&file_name) - .bind(processed_count) + .bind(*total_processed_count) .bind(progress_percent) .execute(&state.pool) .await