Repository navigation
Cherrypick/fix misc bugs 8 #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8ff3d53
1856e49
679edc3
2a352a7
7a5666b
8797bad
d98dd03
730de03
a7d46d8
5013d7c
8b0db55
e4dd8aa
fd41ef3
d05a869
10d0167
950e7c9
db76ffe
2208787
92bb248
97113e1
c5a1d69
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,6 +71,14 @@ use std::ffi::OsStr; | |
| pub trait Watcher: Send + Sync { | ||
| fn add(&self, path: &Path) -> Result<()>; | ||
| fn remove(&self, path: &Path) -> Result<()>; | ||
|
|
||
| /// Add `path` and resolve once its OS watch is in place, so no change made | ||
| /// after it resolves can be missed. `add` may return before then (a new | ||
| /// FSEvents watch is applied on a watcher thread). Waiting never blocks a | ||
| /// thread. | ||
| fn add_and_wait<'a>(&'a self, path: &'a Path) -> BoxFuture<'a, Result<()>> { | ||
| Box::pin(async move { self.add(path) }) | ||
| } | ||
| } | ||
|
|
||
| #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug)] | ||
|
|
@@ -1075,13 +1083,15 @@ impl Fs for RealFs { | |
| let (tx, rx) = async_channel::unbounded(); | ||
| let pending_paths: Arc<Mutex<Vec<PathEvent>>> = Default::default(); | ||
|
|
||
| let watcher: Arc<dyn Watcher> = Arc::new(fs_watcher::FsWatcher::new( | ||
| let watcher = Arc::new(fs_watcher::FsWatcher::new( | ||
| executor.clone(), | ||
| tx.clone(), | ||
| pending_paths.clone(), | ||
| )); | ||
|
|
||
| if let Err(e) = watcher.add(path) { | ||
| // Awaited rather than queued, so a change made after `watch` returns is | ||
| // never missed; the OS work runs on the watcher thread either way. | ||
| if let Err(e) = watcher.add_and_wait(path).await { | ||
| log::warn!("Failed to watch {}:\n{e}", path.display()); | ||
| } | ||
|
|
||
|
|
@@ -1097,11 +1107,12 @@ impl Fs for RealFs { | |
| target = SanitizedPath::new(&canonical).as_path().to_path_buf(); | ||
| } | ||
| } | ||
| watcher.add(&target).ok(); | ||
| watcher.add_and_wait(&target).await.ok(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If asynchronous registration of a symlink target fails, such as after an FSEvents restart or watcher-limit error, AGENTS.md reference: AGENTS.md:L8-L11 Useful? React with 👍 / 👎. |
||
| if let Some(parent) = target.parent() { | ||
| watcher.add(parent).log_err(); | ||
| watcher.add_and_wait(parent).await.log_err(); | ||
| } | ||
| } | ||
| let watcher: Arc<dyn Watcher> = watcher; | ||
|
|
||
| ( | ||
| Box::pin(rx.filter_map({ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.