Fix #294 - Failure to unlink directories should return an EPERM error
This commit is contained in:
parent
af5eea103a
commit
8c00b856bc
|
@ -54,7 +54,7 @@ var errors = {};
|
||||||
'47:EEXIST:file already exists',
|
'47:EEXIST:file already exists',
|
||||||
//'48:ESRCH:no such process',
|
//'48:ESRCH:no such process',
|
||||||
//'49:ENAMETOOLONG:name too long',
|
//'49:ENAMETOOLONG:name too long',
|
||||||
//'50:EPERM:operation not permitted',
|
'50:EPERM:operation not permitted',
|
||||||
'51:ELOOP:too many symbolic links encountered',
|
'51:ELOOP:too many symbolic links encountered',
|
||||||
//'52:EXDEV:cross-device link not permitted',
|
//'52:EXDEV:cross-device link not permitted',
|
||||||
'53:ENOTEMPTY:directory not empty',
|
'53:ENOTEMPTY:directory not empty',
|
||||||
|
|
|
@ -1044,7 +1044,7 @@ function unlink_node(context, path, callback) {
|
||||||
if(error) {
|
if(error) {
|
||||||
callback(error);
|
callback(error);
|
||||||
} else if(result.mode === 'DIRECTORY') {
|
} 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 {
|
} else {
|
||||||
update_file_node(null, result);
|
update_file_node(null, result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ describe('fs.unlink', function() {
|
||||||
|
|
||||||
fs.unlink('/mydir', function (error) {
|
fs.unlink('/mydir', function (error) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(error.code).to.equal('EISDIR');
|
expect(error.code).to.equal('EPERM');
|
||||||
|
|
||||||
fs.stat('/mydir', function (error, stats) {
|
fs.stat('/mydir', function (error, stats) {
|
||||||
expect(error).not.to.exist;
|
expect(error).not.to.exist;
|
||||||
|
|
Loading…
Reference in New Issue