diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2016-03-17 00:21:05 +0300 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2016-03-17 00:21:05 +0300 |
commit | a01c628ebc9ddd7d88c84ae9bb32e29a8aad9c11 (patch) | |
tree | 300638c42504b4afdb41bd02a37d21b090b9365b /lib | |
parent | 4c0b6586dc88a67c4049de9ec7bdeb8c1fee6975 (diff) |
FileStream: should emit 'close' and potentially 'error'
Diffstat (limited to 'lib')
-rw-r--r-- | lib/file-stream.js | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/file-stream.js b/lib/file-stream.js index bbb590e..9402573 100644 --- a/lib/file-stream.js +++ b/lib/file-stream.js @@ -82,10 +82,13 @@ FileStream.prototype._notify = function () { self._piece += 1 } -FileStream.prototype.destroy = function () { +FileStream.prototype.destroy = function (err) { if (this.destroyed) return this.destroyed = true if (!this._torrent.destroyed) { this._torrent.deselect(this._startPiece, this._endPiece, true) } + + if (err) this.emit('error', err) + this.emit('close') } |