fix #41 by reporting nodeError if first directory fails

This commit is contained in:
AJ ONeal 2015-01-05 18:15:46 -07:00
parent 01a28a0d2b
commit 0d6bda5385
1 ha cambiato i file con 9 aggiunte e 3 eliminazioni

Vedi File

@ -159,25 +159,31 @@
me._wfnodegroups = fnodeGroups;
me._wcurfiles = files;
// no error, great
if (!err) {
me._wReadFiles();
return;
}
// error? not first run? => directory error
if (!me._wfirstrun) {
me.emit('directoryError', me._wcurpath, { error: err }, noop);
me._wReadFiles();
return;
}
// error? first run? => maybe a file, maybe a true error
me._wfirstrun = false;
// TODO how to remove this anony?
// readdir failed, try stat (might be a file)
me._wcurpath = me._wcurpath.replace(/^.*\/$/, '');
fs[me._wStat](me._wcurpath, function (e, stat) {
if (stat) {
files = [me._wcurpath.replace(/.*\//, '')];
files = [me._wcurpath];
me._wcurpath = me._wcurpath.replace(files[0], '');
} else {
me.emit('nodeError', me._wcurpath, { error: err }, noop);
}
me._wReadFiles();