From 5ce6224111ebca9b37463647403c5347ee295767 Mon Sep 17 00:00:00 2001 From: Sashko Stubailo Date: Thu, 15 Jan 2015 17:28:53 -0800 Subject: [PATCH] Make rm_recursive synchronous if not in fiber --- tools/files.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/files.js b/tools/files.js index 148e3edd1f..af60d992cb 100644 --- a/tools/files.js +++ b/tools/files.js @@ -250,12 +250,15 @@ files.statOrNull = function (path) { } }; - // Like rm -r. files.rm_recursive = function (p) { - var fut = new Future(); - rimraf(convertToOSPath(p), { busyTries: 10 }, fut.resolver()); - fut.wait(); + if (Fiber.current && Fiber.yield && ! Fiber.yield.disallowed) { + var fut = new Future(); + rimraf(convertToOSPath(p), { busyTries: 10 }, fut.resolver()); + fut.wait(); + } else { + rimraf.sync(convertToOSPath(p)); + } }; // Makes all files in a tree read-only.