Skip to content

Commit 9a7092c

Browse files
fix(deps): update rust crate notify to v7 (v2) (#1999)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: FabianLars <[email protected]>
1 parent 606fa08 commit 9a7092c

File tree

4 files changed

+40
-38
lines changed

4 files changed

+40
-38
lines changed

Cargo.lock

Lines changed: 25 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/api/src-tauri/capabilities/desktop.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
"updater:default",
1010
"global-shortcut:allow-unregister",
1111
"global-shortcut:allow-register",
12-
"global-shortcut:allow-unregister-all"
12+
"global-shortcut:allow-unregister-all",
13+
{ "identifier": "fs:allow-watch", "allow": ["*", "**/*"] },
14+
"fs:allow-unwatch"
1315
]
1416
}

plugins/fs/Cargo.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ url = { workspace = true }
3535
anyhow = "1"
3636
uuid = { version = "1", features = ["v4"] }
3737
glob = "0.3"
38-
notify = { version = "6", optional = true, features = ["serde"] }
39-
notify-debouncer-full = { version = "0.3", optional = true }
38+
# TODO: Remove `serialization-compat-6` in v3
39+
notify = { version = "7", optional = true, features = [
40+
"serde",
41+
"serialization-compat-6",
42+
] }
43+
notify-debouncer-full = { version = "0.4", optional = true }
4044
dunce = { workspace = true }
4145
percent-encoding = "2"
4246

plugins/fs/src/watcher.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// SPDX-License-Identifier: MIT
44

55
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};
77
use serde::Deserialize;
88
use tauri::{
99
ipc::{Channel, CommandScope, GlobalScope},
@@ -47,7 +47,7 @@ impl WatcherResource {
4747
impl Resource for WatcherResource {}
4848

4949
enum 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

Comments
 (0)