Commit graph

146 commits

Author SHA1 Message Date
3554794234
fix(kqueue): add per-file watches to detect modifications and fix rename ordering
kqueue's NOTE_WRITE on a directory fires only when directory entries are
added or removed, not when file contents change. This meant writes to
existing files were never reported as 'modified' events on macOS/FreeBSD.

Fix by maintaining a second set of kqueue watches on individual files
(file_watches), registered with NOTE_WRITE|NOTE_EXTEND. When either flag
fires on a file fd, a 'modified' event is emitted. File watches are
registered in take_snapshot (for files already present when watch() is
called) and in scan_dir (for newly created files), and deregistered when
files are deleted or the directory is unwatched.

Also fix two related bugs:
- NOTE_DELETE was incorrectly defined as 0x04 (NOTE_EXTEND); the correct
  value is 0x01. This could cause NOTE_EXTEND events on watched directories
  to be misreported as directory-deleted events.
- scan_dir emitted created events before deleted events, so a rename
  (old name disappears, new name appears) reported the destination before
  the source. Swapped the order so deletions are always emitted first.

Simplify thread_fn/arm to pass *KQueueBackend directly now that the backend
lives at a stable heap address inside the heap-allocated Interceptor.

All 10 integration tests now pass on FreeBSD.
2026-03-07 20:18:05 +01:00
ae4b56b62a
fix: dangling interceptor crash 2026-03-07 20:02:40 +01:00
9b4d7c2121
feat: implement auto subdirectory watching for platforms that don't watch trees 2026-03-07 19:54:49 +01:00
9dda7efc25
refactor: add a little flair 2026-03-07 19:24:40 +01:00
4569a33382
fix: windows build 2026-03-07 19:20:30 +01:00
e4cc1b82fe
feat: add basic command line executable 2026-03-07 19:10:48 +01:00
f3463dd0dc
fix(kqueue): emit scan_dir events outside the snapshot lock
Handler callbacks invoked while holding snapshots_mutex could deadlock if
the handler called watch() or unwatch(), which also acquires that lock.
Refactor scan_dir to collect all pending events (dir_created, created,
deleted) into temporary lists under the lock, then emit them after
releasing it. Also consolidate the two directory iteration passes into one.
2026-03-07 18:19:00 +01:00
8dc759db61
fix: add a watches mutex to kqueue 2026-02-26 14:55:38 +01:00
9679b0cedf
fix: more test fixes 2026-02-26 14:47:38 +01:00
20c167b37d
build: install test executables
This makes cross compiled testing a little easier for now.
2026-02-26 14:47:07 +01:00
8af70c05b6
refactor: improve kqueue add_watch error handling 2026-02-26 14:21:19 +01:00
40d784bd9f
fix: add missing kqueue init handler 2026-02-26 14:13:17 +01:00
272e35b048
build: fix tests build 2026-02-26 14:10:29 +01:00
389082e4ac
build: fix lazy xcode-frameworks dep 2026-02-26 13:52:25 +01:00
f326b73457
build: make FSEvents backend optional and link it against xcode-frameworks 2026-02-26 13:49:01 +01:00
a720697618
build: add flags and xcode-frameworks deps 2026-02-26 13:42:14 +01:00
cf4ce5923a
fix: misc review findings 2026-02-26 13:37:59 +01:00
07fcb900f8 fix: macs build 2026-02-26 13:35:42 +01:00
f34fc3cb93
fix: FSEventsBackend.init 2026-02-26 13:11:39 +01:00
29a701154f
refactor: remove SpawnError 2026-02-26 13:09:44 +01:00
c6281d2433
fix: unwatch cannot error 2026-02-26 13:09:10 +01:00
2c4f752186
refactor: remove blocking mode for now 2026-02-26 13:07:34 +01:00
5df4aae786
refactor: clean-up in FSEventsBackend 2026-02-26 13:06:59 +01:00
92604f9be3
fix: inotify error handling in INotifyBackend.add_watch 2026-02-26 12:46:54 +01:00
4aae8f8b3e
refactor: add integration test suite 2026-02-26 12:46:15 +01:00
6cbf389d81
refactor: handler fixes 2026-02-26 10:26:00 +01:00
03e431c850
refactor: move to an independent handler model 2026-02-26 10:25:00 +01:00
a1e5e3e9a5
build: add initial zig package 2026-02-22 20:44:20 +01:00
db5b5217ba
fix: re-arm fd_watcher in handle_read_ready 2026-02-22 19:51:36 +01:00
a4abfaea80
refactor: add watches for newly created directories 2026-02-22 19:51:36 +01:00
b8e046d26a
refactor: re-work windows backend to direct send notifications 2026-02-22 19:51:36 +01:00
e9ef810d81
refactor: re-write FSEvents backend to use FSEventStreamSetDispatchQueue 2026-02-22 19:51:36 +01:00
b6d3780283
refactor: add directory snapshotting and diffing to kqueue backend 2026-02-22 19:51:35 +01:00
a6c6aeeb4b
refactor: drop watcher Backend.threaded 2026-02-22 19:51:35 +01:00
ad4b69915c
refactor: remove dead drain functions 2026-02-22 19:51:35 +01:00
db0cced754
fix: use correct destination pid when starting backends 2026-02-22 19:51:35 +01:00
8116066816
refactor: direct send from kqueue background thread 2026-02-22 19:51:35 +01:00
7da00d6a64
refactor: add an FSEvents based backend for macos 2026-02-22 19:51:35 +01:00
bfc5cc6fa5
refactor: improve error handling 2026-02-22 19:48:06 +01:00
30b8fc399b
refactor: switch to blocking thread instead of polling 2026-02-22 19:47:58 +01:00
740ad23c77
refactor: switch to polling kqueue backend for macos/freebsd 2026-02-22 19:47:50 +01:00
b3e9ffb2c9
refactor: consistently use @This() 2026-02-22 19:47:44 +01:00
aaceb03274
fix: freebsd build
Also, rename backends to more closely reflect what they really are.
2026-02-22 19:47:39 +01:00
3f132173d5
fix: windows build 2026-02-22 19:47:23 +01:00
7672eb3c51
refactor: add support for atomic rename events on linux 2026-02-22 19:47:03 +01:00
8ffcb0e732
feat: add nightwatch module 2026-02-22 19:46:51 +01:00