|
|
@ -190,7 +190,8 @@ function onwrite(stream, er) { |
|
|
|
cb(); |
|
|
|
} |
|
|
|
|
|
|
|
if (state.length === 0 && (state.ended || state.ending)) { |
|
|
|
if (state.length === 0 && (state.ended || state.ending) && |
|
|
|
!state.finished && !state.finishing) { |
|
|
|
// emit 'finish' at the very end.
|
|
|
|
state.finishing = true; |
|
|
|
stream.emit('finish'); |
|
|
@ -245,7 +246,7 @@ Writable.prototype.end = function(chunk, encoding) { |
|
|
|
state.ending = true; |
|
|
|
if (chunk) |
|
|
|
this.write(chunk, encoding); |
|
|
|
else if (state.length === 0) { |
|
|
|
else if (state.length === 0 && !state.finishing && !state.finished) { |
|
|
|
state.finishing = true; |
|
|
|
this.emit('finish'); |
|
|
|
state.finished = true; |
|
|
|