diff --git a/changelog.d/20996_recursive_config_watcher.fix.md b/changelog.d/20996_recursive_config_watcher.fix.md new file mode 100644 index 0000000000000..42c07bcf10784 --- /dev/null +++ b/changelog.d/20996_recursive_config_watcher.fix.md @@ -0,0 +1,3 @@ +Fixes an issue where the configuration watcher did not properly handle recursive directories, ensuring configuration will be reloaded in the automatic-namespacing scenario. + +authors: ifuryst \ No newline at end of file diff --git a/src/config/watcher.rs b/src/config/watcher.rs index bff6fbe7965fe..64dcbd0d99fc2 100644 --- a/src/config/watcher.rs +++ b/src/config/watcher.rs @@ -127,7 +127,7 @@ fn create_watcher( #[cfg(unix)] fn add_paths(watcher: &mut RecommendedWatcher, config_paths: &[PathBuf]) -> Result<(), Error> { for path in config_paths { - watcher.watch(path, RecursiveMode::NonRecursive)?; + watcher.watch(path, RecursiveMode::Recursive)?; } Ok(()) } @@ -199,4 +199,23 @@ mod tests { panic!("Test timed out"); } } + + #[tokio::test] + async fn recursive_directory_file_update() { + trace_init(); + + let delay = Duration::from_secs(3); + let dir = temp_dir().to_path_buf(); + let sub_dir = dir.join("sources"); + let file_path = sub_dir.join("input.toml"); + + std::fs::create_dir_all(&sub_dir).unwrap(); + let mut file = File::create(&file_path).unwrap(); + + spawn_thread(&[sub_dir], delay).unwrap(); + + if !test(&mut file, delay * 5).await { + panic!("Test timed out"); + } + } }