MCPcopy Index your code
hub / github.com/nodejs/node / #rescanRecursive

Method #rescanRecursive

lib/internal/vfs/watcher.js:205–227  ·  view source on GitHub ↗

* Recursively rescans for new entries. * @param {string} dirPath The directory path * @param {string} relativePath The relative path from watched root

(dirPath, relativePath)

Source from the content-addressed store, hash-verified

203 * @param {string} relativePath The relative path from watched root
204 */
205 #rescanRecursive(dirPath, relativePath) {
206 try {
207 const entries = this.#vfs.readdirSync(dirPath, { withFileTypes: true });
208 for (const entry of entries) {
209 const fullPath = join(dirPath, entry.name);
210 const relPath = relativePath ?
211 join(relativePath, entry.name) : entry.name;
212
213 if (entry.isDirectory()) {
214 this.#rescanRecursive(fullPath, relPath);
215 } else if (!this.#trackedFiles.has(fullPath)) {
216 const stats = this.#getStatsFor(fullPath);
217 this.#trackedFiles.set(fullPath, {
218 stats,
219 relativePath: relPath,
220 });
221 this.emit('change', 'rename', this.#encodeFilename(relPath));
222 }
223 }
224 } catch {
225 // Directory might not exist or be readable
226 }
227 }
228
229 /**
230 * Gets stats for a specific path.

Callers 1

#pollDirectoryMethod · 0.95

Calls 8

#getStatsForMethod · 0.95
#encodeFilenameMethod · 0.95
hasMethod · 0.65
joinFunction · 0.50
readdirSyncMethod · 0.45
isDirectoryMethod · 0.45
setMethod · 0.45
emitMethod · 0.45

Tested by

no test coverage detected