[Pkg-javascript-commits] [node-graceful-fs] 01/03: New upstream version 4.1.11

Julien Puydt julien.puydt at laposte.net
Tue Nov 29 07:28:19 UTC 2016


This is an automated email from the git hooks/post-receive script.

jpuydt-guest pushed a commit to branch master
in repository node-graceful-fs.

commit d459e1a1282b5c9cb872779a749cad69188ce49d
Author: Julien Puydt <julien.puydt at laposte.net>
Date:   Tue Nov 29 08:27:21 2016 +0100

    New upstream version 4.1.11
---
 package.json                    |  2 +-
 polyfills.js                    | 12 ++++++++++--
 test/windows-rename-polyfill.js | 35 +++++++++++++++++++++++++++++++++++
 3 files changed, 46 insertions(+), 3 deletions(-)

diff --git a/package.json b/package.json
index 50dde50..cde9d0d 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
 {
   "name": "graceful-fs",
   "description": "A drop-in replacement for fs, making various improvements.",
-  "version": "4.1.10",
+  "version": "4.1.11",
   "repository": {
     "type": "git",
     "url": "https://github.com/isaacs/node-graceful-fs"
diff --git a/polyfills.js b/polyfills.js
index ab6b32b..4c6aca7 100644
--- a/polyfills.js
+++ b/polyfills.js
@@ -3,6 +3,9 @@ var constants = require('constants')
 
 var origCwd = process.cwd
 var cwd = null
+
+var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform
+
 process.cwd = function() {
   if (!cwd)
     cwd = origCwd.call(process)
@@ -87,7 +90,7 @@ function patch (fs) {
   // failures. Also, take care to yield the scheduler. Windows scheduling gives
   // CPU to a busy looping process, which can cause the program causing the lock
   // contention to be starved of CPU by node, so the contention doesn't resolve.
-  if (process.platform === "win32") {
+  if (platform === "win32") {
     fs.rename = (function (fs$rename) { return function (from, to, cb) {
       var start = Date.now()
       var backoff = 0;
@@ -96,7 +99,12 @@ function patch (fs) {
             && (er.code === "EACCES" || er.code === "EPERM")
             && Date.now() - start < 60000) {
           setTimeout(function() {
-            fs$rename(from, to, CB);
+            fs.stat(to, function (stater, st) {
+              if (stater && stater.code === "ENOENT")
+                fs$rename(from, to, CB);
+              else
+                cb(er)
+            })
           }, backoff)
           if (backoff < 100)
             backoff += 10;
diff --git a/test/windows-rename-polyfill.js b/test/windows-rename-polyfill.js
new file mode 100644
index 0000000..f48ba74
--- /dev/null
+++ b/test/windows-rename-polyfill.js
@@ -0,0 +1,35 @@
+process.env.GRACEFUL_FS_PLATFORM = 'win32'
+
+var fs = require('fs')
+fs.rename = function (a, b, cb) {
+  setTimeout(function () {
+    var er = new Error('EPERM blerg')
+    er.code = 'EPERM'
+    cb(er)
+  })
+}
+
+var gfs = require('../')
+var t = require('tap')
+var a = __dirname + '/a'
+var b = __dirname + '/b'
+
+t.test('setup', function (t) {
+  try { fs.mkdirSync(a) } catch (e) {}
+  try { fs.mkdirSync(b) } catch (e) {}
+  t.end()
+})
+
+t.test('rename', { timeout: 100 }, function (t) {
+  t.plan(1)
+
+  gfs.rename(a, b, function (er) {
+    t.ok(er)
+  })
+})
+
+t.test('cleanup', function (t) {
+  try { fs.rmdirSync(a) } catch (e) {}
+  try { fs.rmdirSync(b) } catch (e) {}
+  t.end()
+})

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-graceful-fs.git



More information about the Pkg-javascript-commits mailing list