@@ -30,11 +30,12 @@ use std::{
3030 io:: { self , Read , Write } ,
3131 os:: unix:: fs:: PermissionsExt ,
3232 path:: { Path , PathBuf } ,
33- sync:: { mpsc :: channel , Arc , Mutex } ,
33+ sync:: { Arc , Mutex } ,
3434 time:: Duration ,
3535} ;
3636
37- use notify:: { RecommendedWatcher , RecursiveMode , Watcher } ;
37+ use futures:: { channel:: mpsc, SinkExt } ;
38+ use notify:: Watcher ;
3839use regex:: Regex ;
3940
4041pub mod utilities;
@@ -311,16 +312,24 @@ impl MailBackend for MaildirType {
311312
312313 fn watch ( & self ) -> ResultStream < BackendEvent > {
313314 let root_mailbox = self . config . path . to_path_buf ( ) ;
314- let ( tx, rx) = channel ( ) ;
315- let watcher = RecommendedWatcher :: new (
316- tx,
317- notify:: Config :: default ( ) . with_poll_interval ( Duration :: from_secs ( 2 ) ) ,
318- )
319- . and_then ( |mut watcher| {
320- watcher. watch ( & root_mailbox, RecursiveMode :: Recursive ) ?;
321- Ok ( Box :: new ( watcher) )
322- } )
323- . map_err ( |err| err. set_err_details ( "Failed to create file change monitor." ) ) ?;
315+ let ( mut tx, rx) = mpsc:: channel ( 16 ) ;
316+ let watcher = {
317+ let watcher = notify:: RecommendedWatcher :: new (
318+ move |res| {
319+ futures:: executor:: block_on ( async {
320+ _ = tx. send ( res) . await ;
321+ } )
322+ } ,
323+ notify:: Config :: default ( ) . with_poll_interval ( Duration :: from_secs ( 2 ) ) ,
324+ ) ;
325+
326+ watcher
327+ . and_then ( |mut watcher| {
328+ watcher. watch ( & root_mailbox, notify:: RecursiveMode :: Recursive ) ?;
329+ Ok ( Box :: new ( watcher) )
330+ } )
331+ . map_err ( |err| err. set_err_details ( "Failed to create file change monitor." ) ) ?
332+ } ;
324333 let mailbox_counts = self
325334 . mailboxes
326335 . iter ( )
0 commit comments