33// SPDX-License-Identifier: MIT
44
55use 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 } ;
77use serde:: Deserialize ;
88use tauri:: {
99 ipc:: { Channel , CommandScope , GlobalScope } ,
@@ -47,7 +47,7 @@ impl WatcherResource {
4747impl Resource for WatcherResource { }
4848
4949enum WatcherKind {
50- Debouncer ( Debouncer < RecommendedWatcher , FileIdMap > ) ,
50+ Debouncer ( Debouncer < RecommendedWatcher , RecommendedCache > ) ,
5151 Watcher ( RecommendedWatcher ) ,
5252}
5353
@@ -111,16 +111,15 @@ pub async fn watch<R: Runtime>(
111111 let ( tx, rx) = channel ( ) ;
112112 let mut debouncer = new_debouncer ( Duration :: from_millis ( delay) , None , tx) ?;
113113 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) ?;
116115 }
117116 watch_debounced ( on_event, rx) ;
118117 WatcherKind :: Debouncer ( debouncer)
119118 } else {
120119 let ( tx, rx) = channel ( ) ;
121120 let mut watcher = RecommendedWatcher :: new ( tx, Config :: default ( ) ) ?;
122121 for path in & resolved_paths {
123- watcher. watch ( path. as_ref ( ) , recursive_mode) ?;
122+ watcher. watch ( path, recursive_mode) ?;
124123 }
125124 watch_raw ( on_event, rx) ;
126125 WatcherKind :: Watcher ( watcher)
@@ -140,14 +139,14 @@ pub async fn unwatch<R: Runtime>(webview: Webview<R>, rid: ResourceId) -> Comman
140139 match & mut watcher. kind {
141140 WatcherKind :: Debouncer ( ref mut debouncer) => {
142141 for path in & watcher. paths {
143- debouncer. watcher ( ) . unwatch ( path. as_ref ( ) ) . map_err ( |e| {
142+ debouncer. unwatch ( path) . map_err ( |e| {
144143 format ! ( "failed to unwatch path: {} with error: {e}" , path. display( ) )
145144 } ) ?;
146145 }
147146 }
148147 WatcherKind :: Watcher ( ref mut w) => {
149148 for path in & watcher. paths {
150- w. unwatch ( path. as_ref ( ) ) . map_err ( |e| {
149+ w. unwatch ( path) . map_err ( |e| {
151150 format ! ( "failed to unwatch path: {} with error: {e}" , path. display( ) )
152151 } ) ?;
153152 }
0 commit comments