Fix error from non-statable files in HTML view

fixes #6
This commit is contained in:
Douglas Christopher Wilson
2014-05-20 10:14:31 -04:00
parent f7eb0ae92a
commit 027f6dcf54
2 changed files with 19 additions and 4 deletions
+5
View File
@@ -1,3 +1,8 @@
unreleased
==========
* Fix error from non-statable files in HTML view
1.0.2 / 2014-04-28
==================
+14 -4
View File
@@ -281,9 +281,12 @@ function html(files, dir, useIcons, view) {
path.push(encodeURIComponent(file.name));
var date = file.name == '..' ? ''
: file.stat.mtime.toDateString()+' '+file.stat.mtime.toLocaleTimeString();
var size = isDir ? '' : file.stat.size;
var date = file.stat && file.name !== '..'
? file.stat.mtime.toDateString() + ' ' + file.stat.mtime.toLocaleTimeString()
: '';
var size = file.stat && !isDir
? file.stat.size
: '';
return '<li><a href="'
+ normalizeSlashes(normalize(path.join('/')))
@@ -351,7 +354,14 @@ function stat(dir, files, cb) {
files.forEach(function(file){
batch.push(function(done){
fs.stat(join(dir, file), done);
fs.stat(join(dir, file), function(err, stat){
if (err && err.code !== 'ENOENT') {
// pass ENOENT as null stat, not error
return done(err);
}
done(null, stat || null);
});
});
});