diff options
author | Gil Pedersen <git@gpost.dk> | 2012-08-01 16:04:28 +0200 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2012-08-02 01:25:53 +0200 |
commit | f1fba8d1f5e7411f055c00ca4b46646e5b840cf2 (patch) | |
tree | 072e4d7e393ed994bfdca61716f927fa120ec2a7 /lib/fs.js | |
parent | 23f09d7e024f326ea0466af10b97ad46e76ac5e6 (diff) | |
download | node-new-f1fba8d1f5e7411f055c00ca4b46646e5b840cf2.tar.gz |
fs: fix ReadStream / WriteStream missing callback
The (undocumented) callback argument to .destroy() was not called if the
stream was no longer readable / writable.
Diffstat (limited to 'lib/fs.js')
-rw-r--r-- | lib/fs.js | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -1367,7 +1367,10 @@ ReadStream.prototype._emitData = function(d) { ReadStream.prototype.destroy = function(cb) { var self = this; - if (!this.readable) return; + if (!this.readable) { + if (cb) process.nextTick(function() { cb(null); }); + return; + } this.readable = false; function close() { @@ -1570,7 +1573,10 @@ WriteStream.prototype.end = function(data, encoding, cb) { WriteStream.prototype.destroy = function(cb) { var self = this; - if (!this.writable) return; + if (!this.writable) { + if (cb) process.nextTick(function() { cb(null); }); + return; + } this.writable = false; function close() { |