fs: fix symlink error message
authorVladimir Kurchatkin <vladimir.kurchatkin@gmail.com>
Sat, 1 Nov 2014 10:07:03 +0000 (13:07 +0300)
committerChris Dickinson <christopher.s.dickinson@gmail.com>
Sun, 16 Nov 2014 01:01:13 +0000 (17:01 -0800)
the arguments were swapped, so fs.symlink{Sync,} would
report that the wrong file EEXIST'd in error.

Fixes: https://github.com/joyent/node/issues/8651
Fixes: https://github.com/joyent/node/issues/4314
Fixes: https://github.com/joyent/node/issues/5381
PR-URL: https://github.com/joyent/node/pull/8657
Reviewed-by: Chris Dickinson <christopher.s.dickinson@gmail.com>
src/node_file.cc
test/simple/test-fs-error-messages.js

index 5a8d6ea..de43b92 100644 (file)
@@ -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)
   }
 }
 
index 773faa6..16b5dd9 100644 (file)
@@ -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));
 });
@@ -155,6 +159,14 @@ try {
 
 try {
   ++expected;
+  fs.symlinkSync(existingFile, existingFile2);
+} catch (err) {
+  errors.push('symlink');
+  assert.ok(0 <= err.message.indexOf(existingFile2));
+}
+
+try {
+  ++expected;
   fs.unlinkSync(fn);
 } catch (err) {
   errors.push('unlink');