@@ -18,7 +18,7 @@ use anyhow::Context;
1818use glob:: glob;
1919use ignore:: gitignore:: { Gitignore , GitignoreBuilder } ;
2020use notify:: RecursiveMode ;
21- use notify_debouncer_mini :: new_debouncer;
21+ use notify_debouncer_full :: new_debouncer;
2222use serde:: { Deserialize , Deserializer } ;
2323use tauri_bundler:: {
2424 AppCategory , AppImageSettings , BundleBinary , BundleSettings , DebianSettings , DmgSettings ,
@@ -124,15 +124,13 @@ impl Interface for Rust {
124124 fn new ( config : & Config , target : Option < String > ) -> crate :: Result < Self > {
125125 let manifest = {
126126 let ( tx, rx) = sync_channel ( 1 ) ;
127- let mut watcher = new_debouncer ( Duration :: from_secs ( 1 ) , move |r| {
127+ let mut watcher = new_debouncer ( Duration :: from_secs ( 1 ) , None , move |r| {
128128 if let Ok ( events) = r {
129129 let _ = tx. send ( events) ;
130130 }
131131 } )
132132 . unwrap ( ) ;
133- watcher
134- . watcher ( )
135- . watch ( & tauri_dir ( ) . join ( "Cargo.toml" ) , RecursiveMode :: Recursive ) ?;
133+ watcher. watch ( tauri_dir ( ) . join ( "Cargo.toml" ) , RecursiveMode :: Recursive ) ?;
136134 let ( manifest, _modified) = rewrite_manifest ( config) ?;
137135 let now = Instant :: now ( ) ;
138136 let timeout = Duration :: from_secs ( 2 ) ;
@@ -527,7 +525,7 @@ impl Rust {
527525 . expect ( "watch_folders should not be empty" ) ;
528526 let ignore_matcher = build_ignore_matcher ( & common_ancestor) ;
529527
530- let mut watcher = new_debouncer ( Duration :: from_secs ( 1 ) , move |r| {
528+ let mut watcher = new_debouncer ( Duration :: from_secs ( 1 ) , None , move |r| {
531529 if let Ok ( events) = r {
532530 tx. send ( events) . unwrap ( )
533531 }
@@ -539,7 +537,7 @@ impl Rust {
539537 lookup ( & path, |file_type, p| {
540538 if p != path {
541539 log:: debug!( "Watching {} for changes..." , display_path( & p) ) ;
542- let _ = watcher. watcher ( ) . watch (
540+ let _ = watcher. watch (
543541 & p,
544542 if file_type. is_dir ( ) {
545543 RecursiveMode :: Recursive
@@ -555,42 +553,43 @@ impl Rust {
555553 loop {
556554 if let Ok ( events) = rx. recv ( ) {
557555 for event in events {
558- let event_path = event. path ;
559-
560- if !ignore_matcher. is_ignore ( & event_path, event_path. is_dir ( ) ) {
561- if is_configuration_file ( self . app_settings . target , & event_path) {
562- if let Ok ( config) = reload_config ( config. as_ref ( ) ) {
563- let ( manifest, modified) =
564- rewrite_manifest ( config. lock ( ) . unwrap ( ) . as_ref ( ) . unwrap ( ) ) ?;
565- if modified {
566- * self . app_settings . manifest . lock ( ) . unwrap ( ) = manifest;
567- // no need to run the watcher logic, the manifest was modified
568- // and it will trigger the watcher again
569- continue ;
556+ #[ cfg( target_os = "linux" ) ]
557+ if event. kind . is_access ( ) {
558+ continue ;
559+ }
560+
561+ if let Some ( event_path) = event. paths . first ( ) {
562+ if !ignore_matcher. is_ignore ( event_path, event_path. is_dir ( ) ) {
563+ if is_configuration_file ( self . app_settings . target , event_path) {
564+ if let Ok ( config) = reload_config ( config. as_ref ( ) ) {
565+ let ( manifest, modified) =
566+ rewrite_manifest ( config. lock ( ) . unwrap ( ) . as_ref ( ) . unwrap ( ) ) ?;
567+ if modified {
568+ * self . app_settings . manifest . lock ( ) . unwrap ( ) = manifest;
569+ // no need to run the watcher logic, the manifest was modified
570+ // and it will trigger the watcher again
571+ continue ;
572+ }
570573 }
571574 }
572- }
573575
574- log:: info!(
575- "File {} changed. Rebuilding application..." ,
576- display_path(
577- event_path
578- . strip_prefix( frontend_path)
579- . unwrap_or( & event_path)
580- )
581- ) ;
576+ log:: info!(
577+ "File {} changed. Rebuilding application..." ,
578+ display_path( event_path. strip_prefix( frontend_path) . unwrap_or( event_path) )
579+ ) ;
582580
583- let mut p = process. lock ( ) . unwrap ( ) ;
584- p. kill ( ) . with_context ( || "failed to kill app process" ) ?;
581+ let mut p = process. lock ( ) . unwrap ( ) ;
582+ p. kill ( ) . with_context ( || "failed to kill app process" ) ?;
585583
586- // wait for the process to exit
587- // note that on mobile, kill() already waits for the process to exit (duct implementation)
588- loop {
589- if !matches ! ( p. try_wait( ) , Ok ( None ) ) {
590- break ;
584+ // wait for the process to exit
585+ // note that on mobile, kill() already waits for the process to exit (duct implementation)
586+ loop {
587+ if !matches ! ( p. try_wait( ) , Ok ( None ) ) {
588+ break ;
589+ }
591590 }
591+ * p = run ( self ) ?;
592592 }
593- * p = run ( self ) ?;
594593 }
595594 }
596595 }
0 commit comments