Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
pgonzal committed Nov 2, 2018
1 parent 15c339d commit 04c6e82
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions lib/remove/rimraf.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,6 @@ function rmdirSync (p, options, originalEr) {
}
}

function getMilliseconds(lastTime) {
let [seconds, nanoseconds] = process.hrtime(lastTime);
// limit the non-fractional portion to be less than 1^32
return (seconds & 0xffffffff) * 1000 + nanoseconds / 1000000;
}

function rmkidsSync (p, options) {
assert(p)
assert(options)
Expand All @@ -303,15 +297,16 @@ function rmkidsSync (p, options) {
// try really hard to delete stuff on windows, because it has a
// PROFOUNDLY annoying habit of not closing handles promptly when
// files are deleted, resulting in spurious ENOTEMPTY errors.
const startTime = getMilliseconds();
const startTime = Date.now();
do {
console.log(Date.now() - startTime);

try {
const ret = options.rmdirSync(p, options)
return ret
} catch { }

// This comparison uses modular arithmetic since getMilliseconds() can roll over
} while (((getMilliseconds() - startTime) & 0xffffffff) < 500) // give up after 500ms
} while (Date.now() - startTime < 500) // give up after 500ms
} else {
const ret = options.rmdirSync(p, options)
return ret
Expand Down

0 comments on commit 04c6e82

Please sign in to comment.