MCPcopy Create free account
hub / github.com/nodejs/node / #pollDirectory

Method #pollDirectory

lib/internal/vfs/watcher.js:154–175  ·  view source on GitHub ↗

* Polls directory children for changes, detecting new and deleted files.

()

Source from the content-addressed store, hash-verified

152 * Polls directory children for changes, detecting new and deleted files.
153 */
154 #pollDirectory() {
155 // Rescan for new files
156 if (this.#recursive) {
157 this.#rescanRecursive(this.#path, '');
158 } else {
159 this.#rescanChildren(this.#path);
160 }
161
162 // Check tracked files for changes/deletions
163 for (const { 0: filePath, 1: info } of this.#trackedFiles) {
164 const newStats = this.#getStatsFor(filePath);
165 if (newStats === null && info.stats !== null) {
166 // File was deleted
167 this.emit('change', 'rename', this.#encodeFilename(info.relativePath));
168 this.#trackedFiles.delete(filePath);
169 } else if (this.#statsChanged(info.stats, newStats)) {
170 const eventType = this.#determineEventType(info.stats, newStats);
171 this.emit('change', eventType, this.#encodeFilename(info.relativePath));
172 info.stats = newStats;
173 }
174 }
175 }
176
177 /**
178 * Rescans direct children for new entries.

Callers 1

#pollMethod · 0.95

Calls 8

#rescanRecursiveMethod · 0.95
#rescanChildrenMethod · 0.95
#getStatsForMethod · 0.95
#encodeFilenameMethod · 0.95
#statsChangedMethod · 0.95
#determineEventTypeMethod · 0.95
deleteMethod · 0.65
emitMethod · 0.45

Tested by

no test coverage detected