@@ -18,7 +18,7 @@ use anyhow::Context;
18
18
use glob:: glob;
19
19
use ignore:: gitignore:: { Gitignore , GitignoreBuilder } ;
20
20
use notify:: RecursiveMode ;
21
- use notify_debouncer_mini :: new_debouncer;
21
+ use notify_debouncer_full :: new_debouncer;
22
22
use serde:: { Deserialize , Deserializer } ;
23
23
use tauri_bundler:: {
24
24
AppCategory , AppImageSettings , BundleBinary , BundleSettings , DebianSettings , DmgSettings ,
@@ -124,15 +124,13 @@ impl Interface for Rust {
124
124
fn new ( config : & Config , target : Option < String > ) -> crate :: Result < Self > {
125
125
let manifest = {
126
126
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| {
128
128
if let Ok ( events) = r {
129
129
let _ = tx. send ( events) ;
130
130
}
131
131
} )
132
132
. unwrap ( ) ;
133
- watcher
134
- . watcher ( )
135
- . watch ( & tauri_dir ( ) . join ( "Cargo.toml" ) , RecursiveMode :: Recursive ) ?;
133
+ watcher. watch ( tauri_dir ( ) . join ( "Cargo.toml" ) , RecursiveMode :: Recursive ) ?;
136
134
let ( manifest, _modified) = rewrite_manifest ( config) ?;
137
135
let now = Instant :: now ( ) ;
138
136
let timeout = Duration :: from_secs ( 2 ) ;
@@ -527,7 +525,7 @@ impl Rust {
527
525
. expect ( "watch_folders should not be empty" ) ;
528
526
let ignore_matcher = build_ignore_matcher ( & common_ancestor) ;
529
527
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| {
531
529
if let Ok ( events) = r {
532
530
tx. send ( events) . unwrap ( )
533
531
}
@@ -539,7 +537,7 @@ impl Rust {
539
537
lookup ( & path, |file_type, p| {
540
538
if p != path {
541
539
log:: debug!( "Watching {} for changes..." , display_path( & p) ) ;
542
- let _ = watcher. watcher ( ) . watch (
540
+ let _ = watcher. watch (
543
541
& p,
544
542
if file_type. is_dir ( ) {
545
543
RecursiveMode :: Recursive
@@ -555,42 +553,43 @@ impl Rust {
555
553
loop {
556
554
if let Ok ( events) = rx. recv ( ) {
557
555
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
+ }
570
573
}
571
574
}
572
- }
573
575
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
+ ) ;
582
580
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" ) ?;
585
583
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
+ }
591
590
}
591
+ * p = run ( self ) ?;
592
592
}
593
- * p = run ( self ) ?;
594
593
}
595
594
}
596
595
}
0 commit comments