Merge pull request #21770 from Wilfred/vfs_remove_events

fix: Update VFS when a watched file is deleted
This commit is contained in:
Lukas Wirth
2026-03-06 16:39:34 +00:00
committed by GitHub

View File

@@ -208,6 +208,22 @@ impl NotifyActor {
)
})
.filter_map(|path| -> Option<(AbsPathBuf, Option<Vec<u8>>)> {
// Ignore events for files/directories that we're not watching.
if !(self.watched_file_entries.contains(&path)
|| self
.watched_dir_entries
.iter()
.any(|dir| dir.contains_file(&path)))
{
return None;
}
// For removed files, fs::metadata() will return Err, but
// we still want to update the VFS.
if matches!(event.kind, EventKind::Remove(_)) {
return Some((path, None));
}
let meta = fs::metadata(&path).ok()?;
if meta.file_type().is_dir()
&& self
@@ -223,15 +239,6 @@ impl NotifyActor {
return None;
}
if !(self.watched_file_entries.contains(&path)
|| self
.watched_dir_entries
.iter()
.any(|dir| dir.contains_file(&path)))
{
return None;
}
let contents = read(&path);
Some((path, contents))
})