Skip to content

Commit

Permalink
bugfix: init inotify once
Browse files Browse the repository at this point in the history
Signed-off-by: Jonah Beckford <71855677+jonahbeckford@users.noreply.github.com>
  • Loading branch information
jonahbeckford committed Mar 21, 2023
1 parent bf741c4 commit ce2902d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
13 changes: 6 additions & 7 deletions src/dune_file_watcher/dune_file_watcher.ml
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,7 @@ type t =
module Re = Dune_re

let create_should_exclude_predicate ~watch_exclusions =
let exclude_regex watch_exclusions =
Re.compile (Re.alt (List.map watch_exclusions ~f:Re.Posix.re))
in
Re.execp (exclude_regex watch_exclusions)
Re.execp (Re.compile (Re.alt (List.map watch_exclusions ~f:Re.Posix.re)))

module For_tests = struct
let should_exclude = create_should_exclude_predicate
Expand Down Expand Up @@ -478,9 +475,11 @@ let with_buffering ~create ~(scheduler : Scheduler.t) ~debounce_interval =
let create_inotifylib ~scheduler ~should_exclude =
prepare_sync ();
let sync_table = Table.create (module String) 64 in
let inotify = create_inotifylib_watcher ~sync_table ~scheduler in
Inotify_lib.add (inotify should_exclude) (Lazy.force Fs_sync.special_dir);
{ kind = Inotify (inotify should_exclude); sync_table }
let inotify =
create_inotifylib_watcher ~sync_table ~scheduler should_exclude
in
Inotify_lib.add inotify (Lazy.force Fs_sync.special_dir);
{ kind = Inotify inotify; sync_table }

let fsevents_callback ?exclusion_paths (scheduler : Scheduler.t) ~f events =
let skip_path =
Expand Down
4 changes: 2 additions & 2 deletions test/blackbox-tests/test-cases/watching/what-dune-watches.t
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ The pattern below excludes absolute files as Dune currently watches
everything in the PATH, which is not very reproducible.

$ sed -nE 's/inotify_add_watch\([0-9]*, "([^/].*)", .*\) (=.*)/watch \1 \2/p' ../log | sort -u
watch . = 1
watch . = 2
watch _build/.sync = 1
watch src = 2
watch src = 3

Since the pattern above is not reproducible, uncomment the next lines
to see what it is really doing
Expand Down

0 comments on commit ce2902d

Please sign in to comment.