fix: harden folder monitor lifecycle

This commit is contained in:
Sucukdeluxe
2026-08-26 09:24:18 +02:00
parent c414a4a303
commit 724280b0cf
4 changed files with 495 additions and 109 deletions
+2 -1
View File
@@ -5,6 +5,7 @@ async function walkFolderAsync(rootDir, options = {}) {
const fsPromises = options.fsPromises || fs.promises;
const pathImpl = options.pathImpl || path;
const yieldFn = options.yieldFn || (() => new Promise(setImmediate));
const recursive = options.recursive !== false;
const files = [];
const stack = [rootDir];
let scanned = 0;
@@ -20,7 +21,7 @@ async function walkFolderAsync(rootDir, options = {}) {
for (const entry of entries) {
const fullPath = pathImpl.join(dir, entry.name);
if (entry.isDirectory()) {
stack.push(fullPath);
if (recursive) stack.push(fullPath);
} else if (entry.isFile()) {
let size = 0;
try {