From b6cd8a895d3c07dfbc807eeb88e15839ea1e51a6 Mon Sep 17 00:00:00 2001 From: Froidefond Julien Date: Fri, 6 Mar 2026 14:23:17 +0100 Subject: [PATCH] fix(indexer): File watcher not watching directories The setup_watcher function was creating a watcher object but never calling .watch() on the library directories. Now it properly watches all directories recursively and detects file changes. --- apps/indexer/src/main.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/apps/indexer/src/main.rs b/apps/indexer/src/main.rs index ddba2b7..f9341ec 100644 --- a/apps/indexer/src/main.rs +++ b/apps/indexer/src/main.rs @@ -250,12 +250,14 @@ fn setup_watcher( libraries: HashMap, tx: mpsc::Sender<(Uuid, String)>, ) -> anyhow::Result { - let watcher = notify::recommended_watcher(move |res: Result| { + let libraries_for_closure = libraries.clone(); + + let mut watcher = notify::recommended_watcher(move |res: Result| { match res { Ok(event) => { if event.kind.is_modify() || event.kind.is_create() || event.kind.is_remove() { for path in event.paths { - if let Some((library_id, _)) = libraries.iter().find(|(_, root)| { + if let Some((library_id, _)) = libraries_for_closure.iter().find(|(_, root)| { path.starts_with(root) }) { let path_str = path.to_string_lossy().to_string(); @@ -270,6 +272,12 @@ fn setup_watcher( } })?; + // Actually watch the library directories + for (_, root_path) in &libraries { + info!("[WATCHER] Watching directory: {}", root_path); + watcher.watch(std::path::Path::new(root_path), RecursiveMode::Recursive)?; + } + Ok(watcher) }