Enhance VFS initialization and error handling

- Introduced a new method `new_default_with_errors` in the VFS implementation to create a VFS instance with a critical error receiver for monitoring watcher health.
- Updated the `ServeSession` constructor to accept an optional critical error receiver, allowing for better error management during session initialization.
- Adjusted various calls to `ServeSession::new` across the codebase to accommodate the new parameter, ensuring consistent error handling.
- Improved logging in the API context and serve session files for better clarity during server operations.

These changes enhance the robustness of the VFS and session management, providing better tools for error detection and handling.
This commit is contained in:
Joe 2026-02-11 20:13:02 -06:00
parent ec7f91017b
commit 8462c06b82
14 changed files with 1784 additions and 1600 deletions

View file

@ -262,6 +262,17 @@ impl Vfs {
Self::new(StdBackend::new())
}
/// Creates a new `Vfs` with the default backend, also returning
/// the critical error receiver for monitoring watcher health.
///
/// Use this when you need to detect `RescanRequired` errors and
/// trigger a tree reconciliation after lost events.
pub fn new_default_with_errors() -> (Self, crossbeam_channel::Receiver<WatcherCriticalError>) {
let backend = StdBackend::new();
let error_rx = backend.critical_error_receiver();
(Self::new(backend), error_rx)
}
/// Creates a new `Vfs` suitable for one-shot operations like syncback.
///
/// Unlike `new_default()`, this creates a backend that: