diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2016-05-29 03:41:38 +0300 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2016-05-29 03:41:38 +0300 |
commit | 99f8c335a239a6690a9c9f9758457ef90fddbdc2 (patch) | |
tree | 46004a443c4cf954103176d997a9ff17c0230a4a | |
parent | 7673f6cfa3552c150d07d87cc2350ef8e6fdba4c (diff) | |
parent | 78cd54797310f3b3993425019baba0dd68ed4b23 (diff) |
Merge pull request #819 from feross/fix-file-exception
Fix exception in file.js
-rw-r--r-- | lib/file.js | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/file.js b/lib/file.js index c73fc38..ff19a1c 100644 --- a/lib/file.js +++ b/lib/file.js @@ -16,6 +16,7 @@ function File (torrent, file) { EventEmitter.call(this) this._torrent = torrent + this._destroyed = false this.name = file.name this.path = file.path @@ -61,6 +62,7 @@ File.prototype.createReadStream = function (opts) { fileStream._notify() }) eos(fileStream, function () { + if (self._destroyed) return if (!self._torrent.destroyed) { self._torrent.deselect(fileStream._startPiece, fileStream._endPiece, true) } @@ -89,5 +91,6 @@ File.prototype.renderTo = function (elem, cb) { } File.prototype._destroy = function () { + this._destroyed = true this._torrent = null } |