diff --git a/tools/fs/files.js b/tools/fs/files.js index 18c97e41a3..86bb4932db 100644 --- a/tools/fs/files.js +++ b/tools/fs/files.js @@ -55,12 +55,15 @@ const YIELD_ALLOWED = !! ( ! JSON.parse(process.env.METEOR_DISABLE_FS_FIBERS)); function canYield() { - return YIELD_ALLOWED && - Fiber.current && + return Fiber.current && Fiber.yield && ! Fiber.yield.disallowed; } +function mayYield() { + return YIELD_ALLOWED && canYield(); +} + // given a predicate function and a starting path, traverse upwards // from the path until we find a path that satisfies the predicate. // @@ -303,8 +306,7 @@ files.rm_recursive = Profile("files.rm_recursive", (path) => { try { rimraf.sync(files.convertToOSPath(path)); } catch (e) { - if (e.code === "ENOTEMPTY" && - canYield()) { + if (e.code === "ENOTEMPTY" && canYield()) { files.rm_recursive_async(path).await(); return; } @@ -1533,7 +1535,7 @@ function wrapFsFunc(fsFuncName, pathArgIndices, options) { const dirty = options && options.dirty; const dirtyFn = typeof dirty === "function" ? dirty : null; - if (canYield() && + if (mayYield() && shouldBeSync && ! isQuickie) { const promise = new Promise((resolve, reject) => {