From 8c00b856bca5f56161ec88999d114f739fa8bb69 Mon Sep 17 00:00:00 2001 From: gideonthomas Date: Wed, 24 Sep 2014 11:22:29 -0400 Subject: [PATCH] Fix #294 - Failure to unlink directories should return an EPERM error --- src/errors.js | 2 +- src/filesystem/implementation.js | 2 +- tests/spec/fs.unlink.spec.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/errors.js b/src/errors.js index 9e151d3..b30b64b 100644 --- a/src/errors.js +++ b/src/errors.js @@ -54,7 +54,7 @@ var errors = {}; '47:EEXIST:file already exists', //'48:ESRCH:no such process', //'49:ENAMETOOLONG:name too long', - //'50:EPERM:operation not permitted', + '50:EPERM:operation not permitted', '51:ELOOP:too many symbolic links encountered', //'52:EXDEV:cross-device link not permitted', '53:ENOTEMPTY:directory not empty', diff --git a/src/filesystem/implementation.js b/src/filesystem/implementation.js index 51adb17..78670ae 100644 --- a/src/filesystem/implementation.js +++ b/src/filesystem/implementation.js @@ -1044,7 +1044,7 @@ function unlink_node(context, path, callback) { if(error) { callback(error); } else if(result.mode === 'DIRECTORY') { - callback(new Errors.EISDIR('unlink not permitted on directories', name)); + callback(new Errors.EPERM('unlink not permitted on directories', name)); } else { update_file_node(null, result); } diff --git a/tests/spec/fs.unlink.spec.js b/tests/spec/fs.unlink.spec.js index 4492822..de9ca63 100644 --- a/tests/spec/fs.unlink.spec.js +++ b/tests/spec/fs.unlink.spec.js @@ -91,7 +91,7 @@ describe('fs.unlink', function() { fs.unlink('/mydir', function (error) { expect(error).to.exist; - expect(error.code).to.equal('EISDIR'); + expect(error.code).to.equal('EPERM'); fs.stat('/mydir', function (error, stats) { expect(error).not.to.exist;