From 8695b4d32c63e2f986e52528d8384c932411a41e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Wed, 27 May 2020 17:57:27 +0200 Subject: [PATCH] Ignore sentinel events for the FSEvents watcher. This caused the watcher to be endlessly recreated in rapid succession. --- source/eventcore/drivers/posix/watchers.d | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source/eventcore/drivers/posix/watchers.d b/source/eventcore/drivers/posix/watchers.d index ba9de14..5bedf24 100644 --- a/source/eventcore/drivers/posix/watchers.d +++ b/source/eventcore/drivers/posix/watchers.d @@ -338,6 +338,13 @@ final class FSEventsEventDriverWatchers(Events : EventDriverEvents) : EventDrive auto flagsarr = () @trusted { return eventFlags[0 .. numEvents]; } (); auto idarr = () @trusted { return eventIds[0 .. numEvents]; } (); + if (flagsarr[0] & kFSEventStreamEventFlagHistoryDone) { + if (!--numEvents) return; + patharr = patharr[1 .. $]; + flagsarr = flagsarr[1 .. $]; + idarr = idarr[1 .. $]; + } + // A new stream needs to be created after every change, because events // get coalesced per file (event flags get or'ed together) and it becomes // impossible to determine the actual event