Skip to content

Commit

Permalink
Merge pull request #586 from muffs/fix-fs-stat-error
Browse files Browse the repository at this point in the history
fix (server): uncaught error via fs.stat on symlink
  • Loading branch information
vojtajina committed Jul 3, 2013
2 parents b72691c + 74ccc9a commit da47bf2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
25 changes: 15 additions & 10 deletions lib/file-list.js
Expand Up @@ -186,17 +186,22 @@ var List = function(patterns, excludes, emitter, preprocess) {
pending++;
matchedAndNotIgnored++;
fs.stat(path, function(error, stat) {
if (!stat.isDirectory()) {
// TODO(vojta): reuse file objects
var file = new File(path, stat.mtime);

preprocess(file, function() {
buckets[i].push(file);
finish();
});
} else {
log.debug('Ignored directory "%s"', path);
if (error) {
log.debug('An error occured while reading "%s"', path);
finish();
} else {
if (!stat.isDirectory()) {
// TODO(vojta): reuse file objects
var file = new File(path, stat.mtime);

preprocess(file, function() {
buckets[i].push(file);
finish();
});
} else {
log.debug('Ignored directory "%s"', path);
finish();
}
}
});
});
Expand Down
9 changes: 9 additions & 0 deletions test/unit/file-list.spec.coffee
Expand Up @@ -144,6 +144,15 @@ describe 'file-list', ->
expect(files.served).to.exist
done()

it 'should handle fs.stat errors', (done) ->
sinon.stub(mockFs, 'stat').yields([new Error(), null])
list = new m.List patterns('/some/*.js'), [], emitter, preprocessMock

refreshListAndThen (files) ->
mockFs.stat.restore()
done()



#============================================================================
# List.reload()
Expand Down

0 comments on commit da47bf2

Please sign in to comment.