Ensure that fs watches are dropped when dropping the event stream
This commit is contained in:
parent
59366a5c44
commit
43613fe2ac
1 changed files with 4 additions and 2 deletions
|
@ -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 {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue