do not emit create for directory again
This commit is contained in:
parent
f88355ccb5
commit
7f7c4e7465
@ -68,11 +68,11 @@ impl Worker {
|
||||
let watcher_clone = watcher.clone();
|
||||
let (worker, worker_handle) =
|
||||
thread_worker::spawn("vfs", 128, move |input_receiver, output_sender| {
|
||||
let res = input_receiver
|
||||
input_receiver
|
||||
.into_iter()
|
||||
.map(|t| handle_task(t, &watcher_clone))
|
||||
.try_for_each(|it| output_sender.send(it));
|
||||
res.unwrap()
|
||||
.try_for_each(|it| output_sender.send(it))
|
||||
.unwrap()
|
||||
});
|
||||
match Watcher::start(worker.inp.clone()) {
|
||||
Ok(w) => {
|
||||
@ -99,6 +99,7 @@ impl Worker {
|
||||
if let Some(watcher) = self.watcher.lock().take() {
|
||||
let _ = watcher.shutdown();
|
||||
}
|
||||
let _ = self.worker.shutdown();
|
||||
self.worker_handle.shutdown()
|
||||
}
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ impl Watcher {
|
||||
&mut self,
|
||||
dir: &Path,
|
||||
filter_entry: impl Fn(&DirEntry) -> bool,
|
||||
emit_for_existing: bool,
|
||||
emit_for_contents: bool,
|
||||
) {
|
||||
for res in WalkDir::new(dir).into_iter().filter_entry(filter_entry) {
|
||||
match res {
|
||||
@ -98,7 +98,7 @@ impl Watcher {
|
||||
Err(e) => log::warn!("could not watch \"{}\": {}", dir.display(), e),
|
||||
}
|
||||
}
|
||||
if emit_for_existing {
|
||||
if emit_for_contents && entry.depth() > 0 {
|
||||
// emit as create because we haven't seen it yet
|
||||
if let Err(e) =
|
||||
self.sender
|
||||
|
@ -40,9 +40,6 @@ fn test_vfs_works() -> std::io::Result<()> {
|
||||
fs::write(file_path, text)?
|
||||
}
|
||||
|
||||
let gitignore = dir.path().join("a/.gitignore");
|
||||
fs::write(gitignore, "/target").unwrap();
|
||||
|
||||
let a_root = dir.path().join("a");
|
||||
let b_root = dir.path().join("a/b");
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user