From 2720478047300fc67aaea3f7f5d045f7e435ca2f Mon Sep 17 00:00:00 2001 From: Marc Celani Date: Sat, 22 Jan 2022 13:02:14 -0600 Subject: [PATCH 1/2] handle MustScanSubDirs --- lib/fsevents-handler.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/fsevents-handler.js b/lib/fsevents-handler.js index 0f7f2cba..8031da0e 100644 --- a/lib/fsevents-handler.js +++ b/lib/fsevents-handler.js @@ -49,6 +49,9 @@ const { IDENTITY_FN } = require('./constants'); +// See kFSEventStreamEventFlagMustScanSubDirs in FSEvents documentation +const MUST_SCAN_SUBDIRS_FLAG = 1; + const Depth = (value) => isNaN(value) ? {} : {depth: value}; const stat = promisify(fs.stat); @@ -148,6 +151,7 @@ function setFSEventsListener(path, realPath, listener, rawEmitter) { rawEmitter, watcher: createFSEventsInstance(watchPath, (fullPath, flags) => { if (!cont.listeners.size) return; + if (flags & MUST_SCAN_SUBDIRS_FLAG) return; const info = fsevents.getInfo(fullPath, flags); cont.listeners.forEach(list => { list(fullPath, flags, info); From 37a2eaa58d5372f005743e7f4c837021e28350b0 Mon Sep 17 00:00:00 2001 From: Marc Celani Date: Sat, 22 Jan 2022 13:09:11 -0600 Subject: [PATCH 2/2] move to constants --- lib/constants.js | 1 + lib/fsevents-handler.js | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/constants.js b/lib/constants.js index 1454f85b..4743865d 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -24,6 +24,7 @@ exports.FSEVENT_DELETED = 'deleted'; exports.FSEVENT_MOVED = 'moved'; exports.FSEVENT_CLONED = 'cloned'; exports.FSEVENT_UNKNOWN = 'unknown'; +exports.FSEVENT_FLAG_MUST_SCAN_SUBDIRS = 1; exports.FSEVENT_TYPE_FILE = 'file'; exports.FSEVENT_TYPE_DIRECTORY = 'directory'; exports.FSEVENT_TYPE_SYMLINK = 'symlink'; diff --git a/lib/fsevents-handler.js b/lib/fsevents-handler.js index 8031da0e..fe29393c 100644 --- a/lib/fsevents-handler.js +++ b/lib/fsevents-handler.js @@ -37,6 +37,7 @@ const { FSEVENT_MOVED, // FSEVENT_CLONED, FSEVENT_UNKNOWN, + FSEVENT_FLAG_MUST_SCAN_SUBDIRS, FSEVENT_TYPE_FILE, FSEVENT_TYPE_DIRECTORY, FSEVENT_TYPE_SYMLINK, @@ -49,9 +50,6 @@ const { IDENTITY_FN } = require('./constants'); -// See kFSEventStreamEventFlagMustScanSubDirs in FSEvents documentation -const MUST_SCAN_SUBDIRS_FLAG = 1; - const Depth = (value) => isNaN(value) ? {} : {depth: value}; const stat = promisify(fs.stat); @@ -151,7 +149,7 @@ function setFSEventsListener(path, realPath, listener, rawEmitter) { rawEmitter, watcher: createFSEventsInstance(watchPath, (fullPath, flags) => { if (!cont.listeners.size) return; - if (flags & MUST_SCAN_SUBDIRS_FLAG) return; + if (flags & FSEVENT_FLAG_MUST_SCAN_SUBDIRS) return; const info = fsevents.getInfo(fullPath, flags); cont.listeners.forEach(list => { list(fullPath, flags, info);