3
3
// SPDX-License-Identifier: MIT
4
4
5
5
use notify:: { Config , Event , RecommendedWatcher , RecursiveMode , Watcher } ;
6
- use notify_debouncer_full:: { new_debouncer, DebounceEventResult , Debouncer , FileIdMap } ;
6
+ use notify_debouncer_full:: { new_debouncer, DebounceEventResult , Debouncer , RecommendedCache } ;
7
7
use serde:: Deserialize ;
8
8
use tauri:: {
9
9
ipc:: { Channel , CommandScope , GlobalScope } ,
@@ -47,7 +47,7 @@ impl WatcherResource {
47
47
impl Resource for WatcherResource { }
48
48
49
49
enum WatcherKind {
50
- Debouncer ( Debouncer < RecommendedWatcher , FileIdMap > ) ,
50
+ Debouncer ( Debouncer < RecommendedWatcher , RecommendedCache > ) ,
51
51
Watcher ( RecommendedWatcher ) ,
52
52
}
53
53
@@ -111,16 +111,15 @@ pub async fn watch<R: Runtime>(
111
111
let ( tx, rx) = channel ( ) ;
112
112
let mut debouncer = new_debouncer ( Duration :: from_millis ( delay) , None , tx) ?;
113
113
for path in & resolved_paths {
114
- debouncer. watcher ( ) . watch ( path. as_ref ( ) , recursive_mode) ?;
115
- debouncer. cache ( ) . add_root ( path, recursive_mode) ;
114
+ debouncer. watch ( path, recursive_mode) ?;
116
115
}
117
116
watch_debounced ( on_event, rx) ;
118
117
WatcherKind :: Debouncer ( debouncer)
119
118
} else {
120
119
let ( tx, rx) = channel ( ) ;
121
120
let mut watcher = RecommendedWatcher :: new ( tx, Config :: default ( ) ) ?;
122
121
for path in & resolved_paths {
123
- watcher. watch ( path. as_ref ( ) , recursive_mode) ?;
122
+ watcher. watch ( path, recursive_mode) ?;
124
123
}
125
124
watch_raw ( on_event, rx) ;
126
125
WatcherKind :: Watcher ( watcher)
@@ -140,14 +139,14 @@ pub async fn unwatch<R: Runtime>(webview: Webview<R>, rid: ResourceId) -> Comman
140
139
match & mut watcher. kind {
141
140
WatcherKind :: Debouncer ( ref mut debouncer) => {
142
141
for path in & watcher. paths {
143
- debouncer. watcher ( ) . unwatch ( path. as_ref ( ) ) . map_err ( |e| {
142
+ debouncer. unwatch ( path) . map_err ( |e| {
144
143
format ! ( "failed to unwatch path: {} with error: {e}" , path. display( ) )
145
144
} ) ?;
146
145
}
147
146
}
148
147
WatcherKind :: Watcher ( ref mut w) => {
149
148
for path in & watcher. paths {
150
- w. unwatch ( path. as_ref ( ) ) . map_err ( |e| {
149
+ w. unwatch ( path) . map_err ( |e| {
151
150
format ! ( "failed to unwatch path: {} with error: {e}" , path. display( ) )
152
151
} ) ?;
153
152
}
0 commit comments