ack's fix + more tests for various cases
This commit is contained in:
parent
b3da2f7681
commit
1a2774b152
|
@ -573,11 +573,7 @@ function open_file(context, path, flags, callback) {
|
|||
var followedCount = 0;
|
||||
|
||||
if(ROOT_DIRECTORY_NAME == name) {
|
||||
if(_(flags).contains(O_WRITE)) {
|
||||
callback(new Errors.EISDIR('the named file is a directory and O_WRITE is set'));
|
||||
} else {
|
||||
find_node(context, path, set_file_node);
|
||||
}
|
||||
callback(new Errors.EISDIR('the named file is the root directory'));
|
||||
} else {
|
||||
find_node(context, parentPath, read_directory_data);
|
||||
}
|
||||
|
@ -603,8 +599,8 @@ function open_file(context, path, flags, callback) {
|
|||
callback(new Errors.ENOENT('O_CREATE and O_EXCLUSIVE are set, and the named file exists'));
|
||||
} else {
|
||||
directoryEntry = directoryData[name];
|
||||
if(directoryEntry.type == MODE_DIRECTORY && _(flags).contains(O_WRITE)) {
|
||||
callback(new Errors.EISDIR('the named file is a directory and O_WRITE is set'));
|
||||
if(directoryEntry.type == MODE_DIRECTORY) {
|
||||
callback(new Errors.EISDIR('the named file is a directory'));
|
||||
} else {
|
||||
context.getObject(directoryEntry.id, check_if_symbolic_link);
|
||||
}
|
||||
|
|
|
@ -2,11 +2,11 @@ var Filer = require('../..');
|
|||
var util = require('../lib/test-utils.js');
|
||||
var expect = require('chai').expect;
|
||||
|
||||
describe('fs.readFile on a dir path', function() {
|
||||
describe('EISDIR when trying to open a dir path - issue 254', function() {
|
||||
beforeEach(util.setup);
|
||||
afterEach(util.cleanup);
|
||||
|
||||
it('should fail with EISDIR', function(done) {
|
||||
it('should fail with EISDIR for root dir', function(done) {
|
||||
var fs = util.fs();
|
||||
|
||||
fs.readFile('/', function(err) {
|
||||
|
@ -14,4 +14,34 @@ describe('fs.readFile on a dir path', function() {
|
|||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should fail with EISDIR for regular dir', function(done) {
|
||||
var fs = util.fs();
|
||||
|
||||
fs.mkdir('/dir', function(err) {
|
||||
if(err) throw err;
|
||||
|
||||
fs.readFile('/dir', function(err) {
|
||||
expect(err.code).to.equal('EISDIR');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should fail with EISDIR for symlinked dir', function(done) {
|
||||
var fs = util.fs();
|
||||
|
||||
fs.mkdir('/dir', function(err) {
|
||||
if(err) throw err;
|
||||
|
||||
fs.symlink('/dir', '/link', function(err) {
|
||||
if(err) throw err;
|
||||
|
||||
fs.readFile('/link', function(err) {
|
||||
expect(err.code).to.equal('EISDIR');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue