Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion notifykit/_notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ def __init__(
tick_ms: int = 50,
event_buffer_size: int = 1024,
debug: bool = False,
follow_symlinks: bool = True,
filter: Optional[EventFilter] = None,
) -> None:
self._debounce_ms = debounce_ms
self._tick_ms = tick_ms
self._debug = debug

self._watcher = WatcherWrapper(debounce_ms, event_buffer_size, debug)
self._watcher = WatcherWrapper(debounce_ms, event_buffer_size, debug, follow_symlinks)

# Extract filter config to pass to the Rust side
if filter is not None:
Expand Down
1 change: 1 addition & 0 deletions notifykit/_notifykit_lib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class WatcherWrapper:
debounce_ms: int,
event_buffer_size: int = 1024,
debug: bool = False,
follow_symlinks: bool = True,
) -> None: ...
async def watch(self, paths: List[str], recursive: bool = True, ignore_permission_errors: bool = False) -> None: ...
async def unwatch(self, paths: List[str]) -> None: ...
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ pub struct WatcherWrapper {
#[pymethods]
impl WatcherWrapper {
#[new]
fn __init__(debounce_ms: u64, event_buffer_size: usize, debug: bool) -> PyResult<Self> {
let inner =
Watcher::new(debounce_ms, event_buffer_size, debug).map_err(|e| PyOSError::new_err(e.to_string()))?;
fn __init__(debounce_ms: u64, event_buffer_size: usize, debug: bool, follow_symlinks: bool) -> PyResult<Self> {
let inner = Watcher::new(debounce_ms, event_buffer_size, debug, follow_symlinks)
.map_err(|e| PyOSError::new_err(e.to_string()))?;

Ok(WatcherWrapper {
inner: Arc::new(Mutex::new(inner)),
Expand Down
11 changes: 9 additions & 2 deletions src/watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ pub(crate) struct Watcher {
}

impl Watcher {
pub fn new(buffering_time_ms: u64, event_buffer_size: usize, debug: bool) -> Result<Self, notify::Error> {
pub fn new(
buffering_time_ms: u64,
event_buffer_size: usize,
debug: bool,
follow_symlinks: bool,
) -> Result<Self, notify::Error> {
// TODO: hide usage of file cache from Watcher
// let file_cache = FileCache::new();
// let file_cache_c = file_cache.clone();
Expand All @@ -49,6 +54,8 @@ impl Watcher {

let (tx, _rx) = broadcast::channel::<Vec<EventType>>(event_buffer_size);

let config = notify::Config::default().with_follow_symlinks(follow_symlinks);

let inner = RecommendedWatcher::new(
move |e: Result<Event, notify::Error>| {
let mut event_processor = match processor_c.lock() {
Expand All @@ -68,7 +75,7 @@ impl Watcher {
Err(e) => event_processor.add_error(e),
}
},
notify::Config::default(),
config,
)?;

Ok(Self {
Expand Down