Skip to content

Commit

Permalink
fs: fix symlink error message
Browse files Browse the repository at this point in the history
the arguments were swapped, so fs.symlink{Sync,} would
report that the wrong file EEXIST'd in error.

Fixes: nodejs/node-v0.x-archive#8651
Fixes: nodejs/node-v0.x-archive#4314
Fixes: nodejs/node-v0.x-archive#5381
PR-URL: nodejs/node-v0.x-archive#8657
Reviewed-by: Chris Dickinson <christopher.s.dickinson@gmail.com>
  • Loading branch information
vkurchatkin authored and chrisdickinson committed Nov 16, 2014
1 parent 00d7b13 commit f6556b6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -515,9 +515,9 @@ static void Symlink(const FunctionCallbackInfo<Value>& args) {
}

if (args[3]->IsFunction()) {
ASYNC_DEST_CALL(symlink, args[3], *dest, *dest, *path, flags)
ASYNC_DEST_CALL(symlink, args[3], *path, *dest, *path, flags)
} else {
SYNC_DEST_CALL(symlink, *path, *dest, *dest, *path, flags)
SYNC_DEST_CALL(symlink, *dest, *path, *dest, *path, flags)
}
}

Expand Down
12 changes: 12 additions & 0 deletions test/simple/test-fs-error-messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ fs.link(existingFile, existingFile2, function(err) {
assert.ok(0 <= err.message.indexOf(existingFile2));
});

fs.symlink(existingFile, existingFile2, function(err) {
assert.ok(0 <= err.message.indexOf(existingFile2));
});

fs.unlink(fn, function(err) {
assert.ok(0 <= err.message.indexOf(fn));
});
Expand Down Expand Up @@ -153,6 +157,14 @@ try {
assert.ok(0 <= err.message.indexOf(existingFile2));
}

try {
++expected;
fs.symlinkSync(existingFile, existingFile2);
} catch (err) {
errors.push('symlink');
assert.ok(0 <= err.message.indexOf(existingFile2));
}

try {
++expected;
fs.unlinkSync(fn);
Expand Down

0 comments on commit f6556b6

Please sign in to comment.