mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-22 21:41:37 +00:00
Refactor StdBackend error handling for file watcher reliability
- Updated the `new` method in `StdBackend` to improve error handling for file watching. - Introduced specific handling for `WatcherCriticalError::RescanRequired`, allowing the watcher to recover from rapid changes while logging a warning. - Ensured that all other critical errors will terminate the process, maintaining reliability in file watching operations.
This commit is contained in:
parent
fa5393121e
commit
a2c8a583a6
1 changed files with 21 additions and 3 deletions
|
|
@ -64,11 +64,29 @@ pub struct StdBackend {
|
|||
}
|
||||
|
||||
impl StdBackend {
|
||||
/// Creates a new StdBackend with default error handling (logs and exits on critical errors).
|
||||
/// Creates a new StdBackend with default error handling.
|
||||
///
|
||||
/// `RescanRequired` is treated as recoverable (the debouncer will re-walk
|
||||
/// the directory tree). All other critical errors terminate the process
|
||||
/// because file watching cannot continue.
|
||||
pub fn new() -> StdBackend {
|
||||
Self::new_with_error_handler(Box::new(|err| {
|
||||
log::error!("{}. File watching is no longer reliable.", err);
|
||||
std::process::exit(1);
|
||||
match &err {
|
||||
WatcherCriticalError::RescanRequired => {
|
||||
// Recoverable: the debouncer lost some events due to rapid
|
||||
// changes and will rescan the watched directories. Log a
|
||||
// warning but keep the watcher thread alive.
|
||||
log::warn!(
|
||||
"File watcher requested rescan due to rapid changes. \
|
||||
Some file events may have been missed."
|
||||
);
|
||||
false // keep watcher running
|
||||
}
|
||||
_ => {
|
||||
log::error!("{}. File watching is no longer reliable.", err);
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue