fixes to fixes

This commit is contained in:
AJ ONeal 2015-01-05 19:06:32 -07:00
förälder 24d237ae74
incheckning a72cd5e478
2 ändrade filer med 25 tillägg och 7 borttagningar

Visa fil

@ -77,6 +77,7 @@
if (err) {
stat.error = err;
//me.emit('error', curpath, stat);
// TODO v3.0 (don't noop the next if there are listeners)
me.emit('nodeError', me._wcurpath, stat, noop);
me._wfnodegroups.errors.push(stat);
me._wCurFileCallback();
@ -127,6 +128,8 @@
;
if (me._wfnodegroups.errors.length) {
// TODO v3.0 (don't noop the next)
// .errors is an array of stats with { name: name, error: error }
me.emit('errors', me._wcurpath, me._wfnodegroups.errors, noop);
}
// XXX emitNodeTypes still needs refactor
@ -154,6 +157,8 @@
Walker.prototype._wReaddirHandler = function (err, files) {
var fnodeGroups = TypeEmitter.createNodeGroups()
, me = this
, parent
, child
;
me._wfnodegroups = fnodeGroups;
@ -165,9 +170,15 @@
return;
}
// TODO path.sep
me._wcurpath = me._wcurpath.replace(/\/$/, '');
// error? not first run? => directory error
if (!me._wfirstrun) {
// TODO v3.0 (don't noop the next if there are listeners)
me.emit('directoryError', me._wcurpath, { error: err }, noop);
// TODO v3.0
//me.emit('directoryError', me._wcurpath.replace(/^(.*)\/.*$/, '$1'), { name: me._wcurpath.replace(/^.*\/(.*)/, '$1'), error: err }, noop);
me._wReadFiles();
return;
}
@ -175,15 +186,22 @@
// error? first run? => maybe a file, maybe a true error
me._wfirstrun = false;
// readdir failed, try stat (might be a file)
me._wcurpath = me._wcurpath.replace(/^.*\/$/, '');
fs[me._wStat](me._wcurpath, function (e, stat) {
// readdir failed (might be a file), try a stat on the parent
parent = me._wcurpath.replace(/^(.*)\/.*$/, '$1');
fs[me._wStat](parent, function (e, stat) {
if (stat) {
files = [me._wcurpath];
me._wcurpath = me._wcurpath.replace(files[0], '');
// success
// now try stat on this as a child of the parent directory
child = me._wcurpath.replace(/^.*\/(.*)$/, '$1');
files = [child];
me._wcurpath = parent;
} else {
me.emit('nodeError', me._wcurpath, { error: e }, noop);
// TODO v3.0
//me.emit('directoryError', me._wcurpath.replace(/^(.*)\/.*$/, '$1'), { name: me._wcurpath.replace(/^.*\/(.*)/, '$1'), error: err }, noop);
// TODO v3.0 (don't noop the next)
// the original readdir error, not the parent stat error
me.emit('nodeError', me._wcurpath, { error: err }, noop);
}
me._wReadFiles();

Visa fil

@ -17,7 +17,7 @@
},
"lib": ".",
"main": "./lib/walk.js",
"version": "2.3.7",
"version": "2.3.8",
"repository": {
"url": "git://github.com/coolaj86/node-walk.git"
},