mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-09-24 21:40:48 +02:00
fix(fs): log file watcher errors (#3621)
In plugins/fs/src/watcher.rs, notify errors were discarded (TODO), so a watch that died left no trace. They are now logged with log::error!. Reporting them to the JS callback would change the event payload and is deferred to v3.
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
fs: patch
|
||||||
|
fs-js: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
File watcher errors (e.g. the watched directory was removed or the inotify limit was reached) are now logged instead of being silently dropped.
|
||||||
@@ -69,13 +69,18 @@ pub fn watch<R: Runtime>(
|
|||||||
let mut debouncer = new_debouncer(
|
let mut debouncer = new_debouncer(
|
||||||
Duration::from_millis(delay),
|
Duration::from_millis(delay),
|
||||||
None,
|
None,
|
||||||
move |events: Result<Vec<DebouncedEvent>, Vec<notify::Error>>| {
|
move |events: Result<Vec<DebouncedEvent>, Vec<notify::Error>>| match events {
|
||||||
if let Ok(events) = events {
|
Ok(events) => {
|
||||||
for event in events {
|
for event in events {
|
||||||
// TODO: Should errors be emitted too?
|
|
||||||
let _ = on_event.send(event.event);
|
let _ = on_event.send(event.event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// TODO(v3): report the errors to the webview
|
||||||
|
Err(errors) => {
|
||||||
|
for error in errors {
|
||||||
|
log::error!("file watcher error: {error}");
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
for path in &resolved_paths {
|
for path in &resolved_paths {
|
||||||
@@ -84,11 +89,12 @@ pub fn watch<R: Runtime>(
|
|||||||
WatcherKind::Debouncer(debouncer)
|
WatcherKind::Debouncer(debouncer)
|
||||||
} else {
|
} else {
|
||||||
let mut watcher = RecommendedWatcher::new(
|
let mut watcher = RecommendedWatcher::new(
|
||||||
move |event| {
|
move |event: notify::Result<notify::Event>| match event {
|
||||||
if let Ok(event) = event {
|
Ok(event) => {
|
||||||
// TODO: Should errors be emitted too?
|
|
||||||
let _ = on_event.send(event);
|
let _ = on_event.send(event);
|
||||||
}
|
}
|
||||||
|
// TODO(v3): report the errors to the webview
|
||||||
|
Err(error) => log::error!("file watcher error: {error}"),
|
||||||
},
|
},
|
||||||
Config::default(),
|
Config::default(),
|
||||||
)?;
|
)?;
|
||||||
|
|||||||
Reference in New Issue
Block a user