-
-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
win32 rename EPERM: fail fast if target exists
When `rename` is used on Windows, and encounters an EPERM or EACCES error, graceful-fs will retry for up to 30 seconds with gradual backoff to get around file system locking due to A/V etc. This was fixed in 59145ce However, this is a problem if the target exists, which can cause an EPERM or EACCES that is not due to folder locking. This commit causes it to fail fast when an EPERM or EACCES is raised by rename if the target exists. Fix #98
- Loading branch information
Showing
2 changed files
with
45 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
}) |