MCPcopy Create free account
hub / github.com/TechJeeper/Printventory / processDirectory

Function processDirectory

scan-worker.js:284–314  ·  view source on GitHub ↗
(dirPath)

Source from the content-addressed store, hash-verified

282 processDirectory(item.path).finally(() => {
283 activeOps--;
284 processNext();
285 });
286 } else if (item.type === 'file') {
287 processFile(item.path, item.name).finally(() => {
288 activeOps--;
289 processNext();
290 });
291 }
292 }
293 };
294
295 const processDirectory = async (dirPath) => {
296 if (seenDirs.has(dirPath)) return;
297 seenDirs.add(dirPath);
298
299 try {
300 const entries = await fs.promises.readdir(dirPath, { withFileTypes: true });
301 for (const entry of entries) {
302 const fullPath = path.join(dirPath, entry.name);
303
304 if (entry.isDirectory()) {
305 // Skip system directories, __MACOSX, and Printventory extract temp folders
306 if (entry.name.toLowerCase() === '__macosx' ||
307 entry.name === 'printventory-extracts' ||
308 /^(System Volume Information|\$Recycle\.Bin|Windows|Recovery|Boot|EFI)$/i.test(entry.name)) {
309 continue;
310 }
311 // Prioritize files over directories to keep memory usage lower?
312 // Actually directories first might discover more work faster.
313 queue.push({ type: 'dir', path: fullPath });
314 } else {
315 // Only queue model-like files (and zips when enabled). Queuing every file caused
316 // millions of async processFile() calls on large trees even when stat() was skipped.
317 reportTraversedFile();

Callers 1

processNextFunction · 0.85

Calls 2

reportTraversedFileFunction · 0.85
shouldQueueFileFunction · 0.85

Tested by

no test coverage detected