Commit Graph
28 Commits
Author SHA1 Message Date
T. R. Bernstein 442053eae2 Move the event mask into a platform-neutral product
Docs / docs (push) Canceled after 0s
Docs / deploy (push) Canceled after 0s
`InotifyEventMask` took its bits from the C header, so nothing that
imported it could build outside Linux. The new `InotifyMask` product
spells out the kernel constants instead; a Linux test compares each
of them with the header. `Inotify` re-exports the module, so
existing code is unaffected.
2026-09-14 00:13:19 +02:00
T. R. Bernstein c79691cb6f Stop descending into excluded directories
Docs / docs (push) Canceled after 0s
Docs / deploy (push) Canceled after 0s
The resolver skipped an excluded directory in its result but still
walked its subtree, so watches were installed below names such as
`.git` or `node_modules`. Exclusion now prunes the walk.
2026-09-13 23:15:21 +02:00
T. R. Bernstein 134034f3ea Watch directories moved into the tree and report their content
Automatic subtree watching only reacted to `CREATE`, so a directory
moved in from elsewhere stayed unwatched. It is now handled like a
created one. Items that already exist in such a directory never
produce kernel events; they are reported with the same event kind
and `synthesized` set to `true`, so consumers can treat them as
newly appeared.
2026-09-13 23:13:32 +02:00
T. R. Bernstein e6ed232087 Drop watches of directories that leave the tree
A directory moved out of a watched tree kept its kernel watches, so
later changes inside it were reported under the old path. Its
watches and those of its subdirectories are now removed on
`MOVED_FROM`. Watches the kernel reports as `IGNORED` are forgotten
as well, so a reused descriptor number cannot map to a stale path.
2026-09-13 23:10:30 +02:00
T. R. Bernstein 6375a23328 Report queue overflows instead of dropping them
`IN_Q_OVERFLOW` arrives with watch descriptor -1, so the path lookup
failed and the event was silently discarded. It is now delivered
with an empty path so consumers can rescan after the kernel dropped
events.
2026-09-13 23:06:28 +02:00
T. R. Bernstein d2abc3355e Keep every event by default
Events were buffered with `bufferingNewest(512)`, so a burst of
changes silently lost all but the newest 512 events whenever the
consumer lagged. The stream now buffers without limit, and
`init(bufferingPolicy:)` lets callers choose a bounded policy.
2026-09-13 23:00:13 +02:00
T. R. Bernstein dcc08eb928 Cancel the event reader before closing the descriptor
`deinit` closed the inotify descriptor while its dispatch source was
still active. The kernel drops the epoll registration on close, but
libdispatch keeps its own; an instance created afterwards that reuses
the descriptor number could inherit that stale state and never
receive events. Roughly one test run in three lost a single event
this way.

The reader is now cancelled in `deinit` and the descriptor closed in
its cancel handler, as libdispatch requires.
2026-09-13 22:59:15 +02:00
T. R. Bernstein 39f3428bff Propagate first-pass failures in the test task
The two `swift test` passes were joined with `;`, so a failing main
pass was masked by a green limit-test pass.
2026-09-13 22:28:26 +02:00
T. R. Bernstein 8cedee6139 Support swift-subprocess 1.x
The exclusive `from: "0.3.0"` range blocked dependents that already
use swift-subprocess 1.0. Version 1.0 renamed the stdio outputs used
by the task CLI to `currentStandardOutput` and `currentStandardError`.
2026-09-13 22:28:26 +02:00
T. R. Bernstein 10943f9ce3 Make events property of Inotify nonisolated
Docs / docs (push) Has been cancelled
Docs / deploy (push) Has been cancelled
Properties of actors are implicitly isolated. To be able to read the
events stream from any concurrent context, we need to declare it
nonisolated. And as AsyncStream conforms to Sendable, it is safe to make
both events and the private eventStream nonisolated.
2026-03-23 20:15:57 +01:00
T. R. Bernstein 6927464d47 Use Subprocess instead of Shwift
Docs / docs (push) Has been cancelled
Docs / deploy (push) Has been cancelled
Drop Shwift: it is incompatible with musl (used by the Swift static
linking SDK), and its API is not meaningfully more concise than
Subprocess upon closer inspection.
2026-03-23 19:50:58 +01:00
T. R. Bernstein 31ed16c828 Cache build directory of linux containers
SwiftPM uses caches heavily to reduce compilation and download time.
Before this change, we through these caches away with each container.
2026-03-22 17:51:24 +01:00
T. R. Bernstein ac1c86c431 Run linux container with same architechture as host
As the development team uses both Intel and Apple Silicon Macs,
we have to get the host CPU architecture at compilation time instead of
harcoding it.
If the container has a different architecture, the guest has to be
emulated.
2026-03-22 17:51:24 +01:00
T. R. Bernstein 4b28c293cb Use Shwift library instead of Subprocess
Shwift has a concise API, which makes writing shell code nice and easy.
This is an opinionated decision.
2026-03-22 17:51:05 +01:00
T. R. Bernstein 55f3ca2f7b Temporary fix of SwiftPM Bug using task.sh
Docs / docs (push) Has been cancelled
Docs / deploy (push) Has been cancelled
SwiftPM has currently a bug, that products or targets of dependencies
are taken into consideration when resolving names, regardless if they're
used or not by the root package. This stops Swift PM from working on packages,
that declare this package as a dependency and define their own TaskCLI target,
as they collide with the definitions of this package. This is resolved, by
prefixing TaskCLI with the package name.
The product collision - which causes swift run - to run this package's task
executable is resolved, by adding that product only temporarily during task
execution using task.sh.

See https://github.com/swiftlang/swift-package-manager/issues/8482
2026-03-20 21:10:01 +01:00
T. R. Bernstein 134e4e152d Implement watch exclusion lists
Docs / docs (push) Has been cancelled
Docs / deploy (push) Has been cancelled
Allow exclusion of directories when watching recursively.
2026-03-15 22:46:59 +01:00
T. R. Bernstein e2bfb8280b Add generate-docs command to build task
The Swift Docc has to run in a Linux container to be able to build the
documentation, as it needs access to the inotify.h header files.
2026-03-15 22:46:59 +01:00
T. R. Bernstein e78e2c082d Add open source documentation files 2026-03-15 22:46:55 +01:00
T. R. Bernstein 76f91f67a6 Add integration tests for inofity limits
inotify exposes a /proc interface to limit kernel memory usage. If those
limits are set too low, inotify cannot add all watches. The integration
test verifies, that Inotify yields an error in that case.
2026-03-12 14:52:33 +01:00
T. R. Bernstein ffac6d17a5 Implement auto subtree watching of a directory
Allow recursively watching a directory while adding newly created
subdirectories to the inotify watch list.
2026-03-12 12:04:08 +01:00
T. R. Bernstein a8d7fb017f Add data structure for watch descriptor management
For watching whole trees - a change which is upcoming - the watch
descriptor IDs will have to be managed in multiple lists. The
InotifyWatchManager encapsulates the managment logic within a nice API.
2026-03-12 11:32:29 +01:00
T. R. Bernstein b41b82bd0f Implement recursive watching of a directory 2026-03-12 10:36:12 +01:00
T. R. Bernstein d57f998fd4 Use C integer types
Instead of using hardcoded fixed width integers, use C integer types.
As the actual integer size of C depends on the implementation, even if
it is often 32bit, we use the C integer types to guard against cases,
where that is not the case.
2026-03-12 00:32:14 +01:00
T. R. Bernstein 58a05e9b61 Implement async event streaming 2026-03-12 00:22:17 +01:00
T. R. Bernstein 5247d898cd Implement unwatching a path 2026-03-11 18:42:19 +01:00
T. R. Bernstein 564c409c15 Implement watching a path
Each inotify instance produces events for paths in its watch list. Each
item in the watch list is identified by its watch descriptor. Different
paths can be watched for different events.
2026-03-11 18:42:12 +01:00
T. R. Bernstein 098339f9d1 Implement init/deinit of inotify system
Use RAII to handle inotify resource lifetime, i.e. initialize with actor
creation and deinitialize with actor deletion.
2026-03-11 17:50:17 +01:00
T. R. Bernstein 1a7e5ca5de Scaffold project structure 2026-03-11 16:10:48 +01:00