mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-22 21:41:37 +00:00
Enhance file and directory removal logic in VFS
- Added a check for `watch_enabled` before calling `unwatch` in the `remove_file` and `remove_dir_all` methods to prevent unnecessary operations when watching is disabled. - Updated error handling in the `StdBackend` to include a new condition for `Generic` errors related to watch status, improving logging clarity. These changes aim to optimize the file system operations and enhance error handling in the virtual file system.
This commit is contained in:
parent
4f0afe873e
commit
d360ebe66f
2 changed files with 12 additions and 4 deletions
|
|
@ -252,13 +252,17 @@ impl VfsInner {
|
|||
|
||||
fn remove_file<P: AsRef<Path>>(&mut self, path: P) -> io::Result<()> {
|
||||
let path = path.as_ref();
|
||||
if self.watch_enabled {
|
||||
let _ = self.backend.unwatch(path);
|
||||
}
|
||||
self.backend.remove_file(path)
|
||||
}
|
||||
|
||||
fn remove_dir_all<P: AsRef<Path>>(&mut self, path: P) -> io::Result<()> {
|
||||
let path = path.as_ref();
|
||||
if self.watch_enabled {
|
||||
let _ = self.backend.unwatch(path);
|
||||
}
|
||||
self.backend.remove_dir_all(path)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -373,10 +373,14 @@ impl VfsBackend for StdBackend {
|
|||
Ok(())
|
||||
}
|
||||
Err(err) => {
|
||||
if matches!(
|
||||
let is_not_watched = matches!(
|
||||
err.kind,
|
||||
notify::ErrorKind::WatchNotFound | notify::ErrorKind::PathNotFound
|
||||
) {
|
||||
) || matches!(
|
||||
&err.kind,
|
||||
notify::ErrorKind::Generic(msg) if msg.contains("No watch was found")
|
||||
);
|
||||
if is_not_watched {
|
||||
log::trace!(
|
||||
"Path was not directly watched (likely covered by parent): {}",
|
||||
path.display()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue