Ensure that fs watches are dropped when dropping the event stream

This commit is contained in:
Max Brunsfeld 2022-07-18 14:55:24 -07:00
parent 59366a5c44
commit 43613fe2ac

View file

@ -226,11 +226,13 @@ impl Fs for RealFs {
) -> Pin<Box<dyn Send + Stream<Item = Vec<fsevent::Event>>>> { ) -> Pin<Box<dyn Send + Stream<Item = Vec<fsevent::Event>>>> {
let (tx, rx) = smol::channel::unbounded(); let (tx, rx) = smol::channel::unbounded();
let (stream, handle) = EventStream::new(&[path], latency); let (stream, handle) = EventStream::new(&[path], latency);
std::mem::forget(handle);
std::thread::spawn(move || { std::thread::spawn(move || {
stream.run(move |events| smol::block_on(tx.send(events)).is_ok()); stream.run(move |events| smol::block_on(tx.send(events)).is_ok());
}); });
Box::pin(rx) Box::pin(rx.chain(futures::stream::once(async move {
drop(handle);
vec![]
})))
} }
fn is_fake(&self) -> bool { fn is_fake(&self) -> bool {