@@ -428,8 +428,12 @@ fn process_message(conn: &rusqlite::Connection, msg: WriteMessage, stats: &Write
428428/// Starts at `start_id` (typically the parent of the affected entry) and
429429/// walks up to the root sentinel. Each ancestor gets its dir_stats updated
430430/// with the given delta. Creates dir_stats rows if they don't exist.
431+ ///
432+ /// Uses direct SQL statements (no transaction) because this function is
433+ /// always called from within the writer thread, which may already be inside
434+ /// a `BEGIN IMMEDIATE` transaction (for example, during replay).
431435fn propagate_delta_by_id ( conn : & rusqlite:: Connection , start_id : i64 , size_delta : i64 , file_delta : i32 , dir_delta : i32 ) {
432- use crate :: indexing:: store:: { DirStatsById , ROOT_ID } ;
436+ use crate :: indexing:: store:: ROOT_ID ;
433437
434438 let mut current_id = start_id;
435439 while current_id != 0 {
@@ -449,16 +453,13 @@ fn propagate_delta_by_id(conn: &rusqlite::Connection, start_id: i64, size_delta:
449453 ) ,
450454 } ;
451455
452- if let Err ( e) = IndexStore :: upsert_dir_stats_by_id (
453- conn,
454- & [ DirStatsById {
455- entry_id : current_id,
456- recursive_size : new_size,
457- recursive_file_count : new_files,
458- recursive_dir_count : new_dirs,
459- } ] ,
456+ if let Err ( e) = conn. execute (
457+ "INSERT OR REPLACE INTO dir_stats
458+ (entry_id, recursive_size, recursive_file_count, recursive_dir_count)
459+ VALUES (?1, ?2, ?3, ?4)" ,
460+ rusqlite:: params![ current_id, new_size, new_files, new_dirs] ,
460461 ) {
461- log:: warn!( "propagate_delta_by_id: upsert_dir_stats_by_id failed for id={current_id}: {e}" ) ;
462+ log:: warn!( "propagate_delta_by_id: upsert failed for id={current_id}: {e}" ) ;
462463 break ;
463464 }
464465
0 commit comments