Reduced number of elements passed from Rust to Kotlin on file changes

This commit is contained in:
Abdelilah El Aissaoui 2024-05-24 15:16:40 +02:00
parent 0a324f1fe2
commit bc90b46562
No known key found for this signature in database
GPG Key ID: 7587FC860F594869

View File

@ -49,14 +49,17 @@ pub fn watch_directory(
last_update = 0; last_update = 0;
if paths_cached.len() == 1 { if paths_cached.len() == 1 {
let first_path = paths_cached.first().unwrap(); let first_path = paths_cached.first().expect("First path not found!");
let is_dir = PathBuf::from(first_path).is_dir(); let is_dir = PathBuf::from(first_path).is_dir();
if !is_dir { if !is_dir {
notifier.detected_change(paths_cached.to_vec()); notifier.detected_change(paths_cached.to_vec());
} }
} else if !paths_cached.is_empty() { } else if !paths_cached.is_empty() {
println!("Sending batched events to Kotlin side"); paths_cached.sort();
paths_cached.dedup();
println!("Sending {} batched events to Kotlin side", paths_cached.len());
notifier.detected_change(paths_cached.to_vec()); notifier.detected_change(paths_cached.to_vec());
} }