Permalink
Browse files

Proper scope on _writeStream.drain

  • Loading branch information...
bentaber committed Sep 9, 2011
1 parent dc751de commit 078a52fe8d29c855785a7d5f6dc6ee9ca306f053
Showing with 8 additions and 4 deletions.
  1. +2 −1 .gitignore
  2. +6 −3 lib/dirty/dirty.js
View
@@ -1 +1,2 @@
-*.dirty
+*.dirty
+node_modules
View
@@ -135,12 +135,14 @@ Dirty.prototype._load = function() {
flags: 'a'
});
- this._writeStream.on('drain', this._writeDrain);
+ this._writeStream.on('drain', function() {
+ self._writeDrain();
+ });
};
Dirty.prototype._writeDrain = function() {
this.flushing = false;
-
+
if (!this._queue.length) {
this.emit('drain');
} else {
@@ -187,7 +189,7 @@ Dirty.prototype._flush = function() {
}
(function(cbs) {
- if (!this.path) {
+ if (!self.path) {
process.nextTick(function() {
callbacks(null, cbs);
self._writeDrain();
@@ -200,6 +202,7 @@ Dirty.prototype._flush = function() {
self.emit('error', err);
return;
}
+
callbacks(err, cbs);
});
})(cbs);

0 comments on commit 078a52f

Please sign in to comment.