Skip to content

Commit

Permalink
tor-config: Use a polling watcher on non-windows platforms that don't…
Browse files Browse the repository at this point in the history
… have inotify.

On windows and platforms that support inotify (i.e. linux and android),
we continue using the recommended watcher. On platforms that use kqueue,
we switch to a polling watcher to work around a [notify bug] that
manifests when using a non-recursive watcher to watch a directory.

This commit is best reviewed with `git diff --ignore-all-space`.

Closes #1644

[notify bug]: notify-rs/notify#644
  • Loading branch information
gabi-250 committed Oct 16, 2024
1 parent 3e0ed00 commit f397797
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/tor-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ __is_experimental = []

[dependencies]
amplify = { version = "4", default-features = false, features = ["derive"] }
cfg-if = "1.0.0"
derive-deftly = "0.14"
derive_builder = { version = "0.11.2", package = "derive_builder_fork_arti" }
directories = { version = "5", optional = true }
Expand Down
11 changes: 9 additions & 2 deletions crates/tor-config/src/file_watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,15 @@ use futures::{SinkExt as _, Stream, StreamExt as _};
/// `Result` whose `Err` is [`FileWatcherBuildError`].
pub type Result<T> = std::result::Result<T, FileWatcherBuildError>;

/// The concrete type of the underlying watcher.
type NotifyWatcher = notify::RecommendedWatcher;
cfg_if::cfg_if! {
if #[cfg(any(target_os = "linux", target_os = "android", target_os = "windows"))] {
/// The concrete type of the underlying watcher.
type NotifyWatcher = notify::RecommendedWatcher;
} else {
/// The concrete type of the underlying watcher.
type NotifyWatcher = notify::PollWatcher;
}
}

/// A wrapper around a `notify::Watcher` to watch a set of parent
/// directories in order to learn about changes in some specific files that they
Expand Down

0 comments on commit f397797

Please sign in to comment.