From c54fa9f73b2db6b164bd812baadcacfd4e87d046 Mon Sep 17 00:00:00 2001 From: ArjhanToteck <38510221+ArjhanToteck@users.noreply.github.com> Date: Sat, 9 Mar 2024 17:11:46 -0700 Subject: [PATCH] calling both lstat and stat isnt needed in doScan --- lib/DirectoryWatcher.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/DirectoryWatcher.js b/lib/DirectoryWatcher.js index 104f40a..b2bc39f 100644 --- a/lib/DirectoryWatcher.js +++ b/lib/DirectoryWatcher.js @@ -653,12 +653,6 @@ class DirectoryWatcher extends EventEmitter { true, "scan (file)" ); - if ( - this.watcherManager.options.followSymlinks && - stats.isSymbolicLink() - ) { - fs.stat(itemPath, handleStats); - } } else if (stats.isDirectory()) { if (!initial || !this.directories.has(itemPath)) this.setDirectory( @@ -670,7 +664,11 @@ class DirectoryWatcher extends EventEmitter { } itemFinished(); }; - fs.lstat(itemPath, handleStats); + if (this.watcherManager.options.followSymlinks) { + fs.stat(itemPath, handleStats); + } else { + fs.lstat(itemPath, handleStats); + } } itemFinished(); });