@@ -3,7 +3,6 @@ use std::io::{BufWriter, Write};
33use std:: path:: { Path , PathBuf } ;
44use std:: sync:: Arc ;
55use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
6- use std:: time:: Duration ;
76
87use ahash:: { AHashMap as HashMap , AHashSet as HashSet } ;
98use anyhow:: { Context , Result } ;
@@ -293,55 +292,11 @@ fn main() -> Result<()> {
293292 pb. set_message ( "Scanning files..." ) ;
294293 }
295294
296- // Track currently processing files to identify stuck ones
297- let processing_files = Arc :: new ( std:: sync:: Mutex :: new ( HashMap :: < std:: thread:: ThreadId , PathBuf > :: new ( ) ) ) ;
298- let processing_files_clone = processing_files. clone ( ) ;
299-
300- // Spawn a monitor thread that reports stuck files
301- std:: thread:: spawn ( move || {
302- loop {
303- std:: thread:: sleep ( Duration :: from_secs ( 30 ) ) ;
304- let files = processing_files_clone. lock ( ) . unwrap ( ) ;
305- if !files. is_empty ( ) {
306- eprintln ! ( "\n === FILES CURRENTLY BEING PROCESSED (>30s) ===" ) ;
307- for ( thread_id, path) in files. iter ( ) {
308- eprintln ! ( " Thread {:?}: {}" , thread_id, path. display( ) ) ;
309- }
310- eprintln ! ( "===============================================\n " ) ;
311- }
312- }
313- } ) ;
314-
315295 // Process files in parallel with rayon
316296 files_to_scan. into_par_iter ( ) . for_each ( |path| {
317- let thread_id = std:: thread:: current ( ) . id ( ) ;
318-
319- // Register this file as being processed
320- {
321- let mut files = processing_files. lock ( ) . unwrap ( ) ;
322- files. insert ( thread_id, path. clone ( ) ) ;
323- }
324-
325297 // Process the file
326- let result = std:: panic:: catch_unwind ( std:: panic:: AssertUnwindSafe ( || {
327- process_file ( & path, & patterns, & tx)
328- } ) ) ;
329-
330- // Unregister this file
331- {
332- let mut files = processing_files. lock ( ) . unwrap ( ) ;
333- files. remove ( & thread_id) ;
334- }
335-
336- // Handle result
337- match result {
338- Ok ( Ok ( ( ) ) ) => { }
339- Ok ( Err ( err) ) => {
340- eprintln ! ( "Error processing {}: {err:#}" , path. display( ) ) ;
341- }
342- Err ( _) => {
343- eprintln ! ( "PANIC while processing {}" , path. display( ) ) ;
344- }
298+ if let Err ( err) = process_file ( & path, & patterns, & tx) {
299+ eprintln ! ( "Error processing {}: {err:#}" , path. display( ) ) ;
345300 }
346301
347302 scanned_count. fetch_add ( 1 , Ordering :: Relaxed ) ;
0 commit comments