windows: Fix FS-related issues (#23369)
I've noticed an occasional error: `ignoring event C:\some\path\to\file outside of root path \\?\C:\some\path`. This happens because UNC paths always fail to match with non-UNC paths during operations like `strip_prefix` or `starts_with`. To address this, I changed the types of some key parameters to `SanitizedPath`. With this adjustment, FS events are now correctly identified, and under the changes in this PR, the `test_rescan_and_remote_updates` test also passes successfully on Windows. Release Notes: - N/A
This commit is contained in:
parent
8f87b5637a
commit
04c04e8406
4 changed files with 44 additions and 17 deletions
|
@ -1,7 +1,7 @@
|
|||
use notify::EventKind;
|
||||
use parking_lot::Mutex;
|
||||
use std::sync::{Arc, OnceLock};
|
||||
use util::ResultExt;
|
||||
use util::{paths::SanitizedPath, ResultExt};
|
||||
|
||||
use crate::{PathEvent, PathEventKind, Watcher};
|
||||
|
||||
|
@ -24,7 +24,7 @@ impl FsWatcher {
|
|||
|
||||
impl Watcher for FsWatcher {
|
||||
fn add(&self, path: &std::path::Path) -> gpui::Result<()> {
|
||||
let root_path = path.to_path_buf();
|
||||
let root_path = SanitizedPath::from(path);
|
||||
|
||||
let tx = self.tx.clone();
|
||||
let pending_paths = self.pending_path_events.clone();
|
||||
|
@ -44,8 +44,9 @@ impl Watcher for FsWatcher {
|
|||
.paths
|
||||
.iter()
|
||||
.filter_map(|event_path| {
|
||||
let event_path = SanitizedPath::from(event_path);
|
||||
event_path.starts_with(&root_path).then(|| PathEvent {
|
||||
path: event_path.clone(),
|
||||
path: event_path.as_path().to_path_buf(),
|
||||
kind,
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue