Remove the watches a failed tree call had already added

A recursive watch that hit the watch limit or an unreadable directory
threw after adding watches for part of the tree, which stayed in the
instance and kept counting against the user's limit. The call now
leaves the instance as it found it.

The test needs a second instance for the check, because a repeated
watch on the same instance only updates the existing one.
This commit is contained in:
T. R. Bernstein
2026-09-19 00:43:37 +02:00
parent 3c852a565c
commit 21f096aede
3 changed files with 42 additions and 5 deletions
@@ -18,7 +18,7 @@ let descriptors = try await inotify.addRecursiveWatch(
)
```
The returned array contains one watch descriptor per directory. Subdirectories created **after** this call are not covered.
The returned array contains one watch descriptor per directory. Subdirectories created **after** this call are not covered. When one of the directories cannot be watched, for instance because the user's watch limit is reached, the call throws and removes the watches it had added, so the instance is left as it was.
### Automatic Subtree Watching