Extending an automatically watched tree to a new directory swallowed every error, so a reached watch limit or an unreadable directory left part of the tree unwatched without any sign. No call of the consumer is running at that moment, so the failures now arrive in the event stream as InotifyEvent.watchFailed, after the event that triggered the extension. The library watches what it can first: a reached limit ends the attempt, an unreadable directory is skipped with its subtree, and a directory that vanished in between is not reported. The buffer now carries the library's own events next to the kernel's, which keeps them in order and hides the stream's element type. The test runner drops root's DAC capabilities so that an unreadable directory can be tested.
21 lines
996 B
Swift
21 lines
996 B
Swift
import SystemPackage
|
|
|
|
/// What an ``Inotify`` instance delivers: a change to a watched item, or a
|
|
/// condition that affects which changes it can deliver.
|
|
public enum InotifyEvent: Sendable, Hashable {
|
|
/// A change to a watched file or directory.
|
|
case fileSystem(FileSystemEvent)
|
|
/// The kernel's event queue was full, so it dropped events. Consumers
|
|
/// that must not miss changes should rescan the watched trees.
|
|
case queueOverflow
|
|
/// A directory that appeared in a tree watched with automatic subtree
|
|
/// watching could not be watched, so changes below it go unreported.
|
|
///
|
|
/// It follows the event of the directory whose appearance made the
|
|
/// library extend the watch. A reached watch limit ends the extension,
|
|
/// so the directories after the first failed one are not reported
|
|
/// separately. A directory that vanished before it could be watched is
|
|
/// not reported, since its removal arrives as an event of its own.
|
|
case watchFailed(path: FilePath, error: InotifyError)
|
|
}
|