graceful-fs
Advanced tools
Comparing version 4.2.9 to 4.2.10
@@ -194,2 +194,3 @@ var fs = require('fs') | ||
fs.readdir = readdir | ||
var noReaddirOptionVersions = /^v[0-5]\./ | ||
function readdir (path, options, cb) { | ||
@@ -199,8 +200,26 @@ if (typeof options === 'function') | ||
var go$readdir = noReaddirOptionVersions.test(process.version) | ||
? function go$readdir (path, options, cb, startTime) { | ||
return fs$readdir(path, fs$readdirCallback( | ||
path, options, cb, startTime | ||
)) | ||
} | ||
: function go$readdir (path, options, cb, startTime) { | ||
return fs$readdir(path, options, fs$readdirCallback( | ||
path, options, cb, startTime | ||
)) | ||
} | ||
return go$readdir(path, options, cb) | ||
function go$readdir (path, options, cb, startTime) { | ||
return fs$readdir(path, options, function (err, files) { | ||
function fs$readdirCallback (path, options, cb, startTime) { | ||
return function (err, files) { | ||
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE')) | ||
enqueue([go$readdir, [path, options, cb], err, startTime || Date.now(), Date.now()]) | ||
enqueue([ | ||
go$readdir, | ||
[path, options, cb], | ||
err, | ||
startTime || Date.now(), | ||
Date.now() | ||
]) | ||
else { | ||
@@ -213,3 +232,3 @@ if (files && files.sort) | ||
} | ||
}) | ||
} | ||
} | ||
@@ -216,0 +235,0 @@ } |
{ | ||
"name": "graceful-fs", | ||
"description": "A drop-in replacement for fs, making various improvements.", | ||
"version": "4.2.9", | ||
"version": "4.2.10", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "type": "git", |
@@ -74,3 +74,3 @@ var constants = require('constants') | ||
// if lchmod/lchown do not exist, then make them no-ops | ||
if (!fs.lchmod) { | ||
if (fs.chmod && !fs.lchmod) { | ||
fs.lchmod = function (path, mode, cb) { | ||
@@ -81,3 +81,3 @@ if (cb) process.nextTick(cb) | ||
} | ||
if (!fs.lchown) { | ||
if (fs.chown && !fs.lchown) { | ||
fs.lchown = function (path, uid, gid, cb) { | ||
@@ -99,28 +99,34 @@ if (cb) process.nextTick(cb) | ||
if (platform === "win32") { | ||
fs.rename = (function (fs$rename) { return function (from, to, cb) { | ||
var start = Date.now() | ||
var backoff = 0; | ||
fs$rename(from, to, function CB (er) { | ||
if (er | ||
&& (er.code === "EACCES" || er.code === "EPERM") | ||
&& Date.now() - start < 60000) { | ||
setTimeout(function() { | ||
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; | ||
return; | ||
} | ||
if (cb) cb(er) | ||
}) | ||
}})(fs.rename) | ||
fs.rename = typeof fs.rename !== 'function' ? fs.rename | ||
: (function (fs$rename) { | ||
function rename (from, to, cb) { | ||
var start = Date.now() | ||
var backoff = 0; | ||
fs$rename(from, to, function CB (er) { | ||
if (er | ||
&& (er.code === "EACCES" || er.code === "EPERM") | ||
&& Date.now() - start < 60000) { | ||
setTimeout(function() { | ||
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; | ||
return; | ||
} | ||
if (cb) cb(er) | ||
}) | ||
} | ||
if (Object.setPrototypeOf) Object.setPrototypeOf(rename, fs$rename) | ||
return rename | ||
})(fs.rename) | ||
} | ||
// if read() returns EAGAIN, then just try it again. | ||
fs.read = (function (fs$read) { | ||
fs.read = typeof fs.read !== 'function' ? fs.read | ||
: (function (fs$read) { | ||
function read (fd, buffer, offset, length, position, callback_) { | ||
@@ -146,3 +152,4 @@ var callback | ||
fs.readSync = (function (fs$readSync) { return function (fd, buffer, offset, length, position) { | ||
fs.readSync = typeof fs.readSync !== 'function' ? fs.readSync | ||
: (function (fs$readSync) { return function (fd, buffer, offset, length, position) { | ||
var eagCounter = 0 | ||
@@ -206,3 +213,3 @@ while (true) { | ||
function patchLutimes (fs) { | ||
if (constants.hasOwnProperty("O_SYMLINK")) { | ||
if (constants.hasOwnProperty("O_SYMLINK") && fs.futimes) { | ||
fs.lutimes = function (path, at, mt, cb) { | ||
@@ -241,3 +248,3 @@ fs.open(path, constants.O_SYMLINK, function (er, fd) { | ||
} else { | ||
} else if (fs.futimes) { | ||
fs.lutimes = function (_a, _b, _c, cb) { if (cb) process.nextTick(cb) } | ||
@@ -244,0 +251,0 @@ fs.lutimesSync = function () {} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32470
818