fix: harden folder monitor lifecycle
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user