(dirPath)
| 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(); |
no test coverage detected