Implement watch exclusion lists
Some checks failed
Docs / docs (push) Has been cancelled
Docs / deploy (push) Has been cancelled

Allow exclusion of directories when watching recursively.
This commit is contained in:
T. R. Bernstein
2026-03-15 22:30:10 +01:00
parent c87099e4a7
commit 134e4e152d
8 changed files with 115 additions and 25 deletions

View File

@@ -10,9 +10,11 @@ func getEventsForTrigger(
in dir: String,
mask: InotifyEventMask,
recursive: RecursivKind = .nonrecursive,
exclude: [String] = [],
trigger: @escaping (String) async throws -> Void,
) async throws -> [InotifyEvent] {
let watcher = try Inotify()
await watcher.exclude(names: exclude)
switch recursive {
case .nonrecursive:
try await watcher.addWatch(path: dir, mask: mask)