diff options
author | isaacs <i@izs.me> | 2012-09-25 08:28:55 -0700 |
---|---|---|
committer | isaacs <i@izs.me> | 2012-09-25 08:29:05 -0700 |
commit | 83d39c8d535559bb7287c2a670ba256c5e9cb627 (patch) | |
tree | 9c23ad63d4f0ea29192b65da76a11cf95c1fbd1d /deps/npm/node_modules/graceful-fs/graceful-fs.js | |
parent | d5e9895ce0fb708e35216753999b951bae571f39 (diff) | |
download | node-new-83d39c8d535559bb7287c2a670ba256c5e9cb627.tar.gz |
npm: upgrade to 1.1.62
Diffstat (limited to 'deps/npm/node_modules/graceful-fs/graceful-fs.js')
-rw-r--r-- | deps/npm/node_modules/graceful-fs/graceful-fs.js | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/deps/npm/node_modules/graceful-fs/graceful-fs.js b/deps/npm/node_modules/graceful-fs/graceful-fs.js index 5d136c27f9..be9951eacd 100644 --- a/deps/npm/node_modules/graceful-fs/graceful-fs.js +++ b/deps/npm/node_modules/graceful-fs/graceful-fs.js @@ -65,10 +65,8 @@ function open (path, flags, mode, cb) { fs.openSync = function (path, flags, mode) { var ret - try { - ret = originalOpenSync.call(fs, path, flags, mode) - fs._curOpen ++ - } finally {} + ret = originalOpenSync.call(fs, path, flags, mode) + fs._curOpen ++ return ret } @@ -261,7 +259,6 @@ if (!fs.lchown) { - // on Windows, A/V software can lock the directory, causing this // to fail with an EACCES or EPERM if the directory contains newly // created files. Try again on failure, for up to 1 second. @@ -279,3 +276,37 @@ if (process.platform === "win32") { }) } } + + +// if read() returns EAGAIN, then just try it again. +var read = fs.read +fs.read = function (fd, buffer, offset, length, position, callback_) { + var callback + if (callback_ && typeof callback_ === 'function') { + var eagCounter = 0 + callback = function (er, _, __) { + if (er && er.code === 'EAGAIN' && eagCounter < 10) { + eagCounter ++ + return read.call(fs, fd, buffer, offset, length, position, callback) + } + callback_.apply(this, arguments) + } + } + return read.call(fs, fd, buffer, offset, length, position, callback) +} + +var readSync = fs.readSync +fs.readSync = function (fd, buffer, offset, length, position) { + var eagCounter = 0 + while (true) { + try { + return readSync.call(fs, fd, buffer, offset, length, position) + } catch (er) { + if (er.code === 'EAGAIN' && eagCounter < 10) { + eagCounter ++ + continue + } + throw er + } + } +} |