Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix exception in file.js #819

Merged
merged 1 commit into from May 29, 2016
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Fix exception in file.js

If file is destroyed and stream ends afterwards, then an exception is
thrown because self._torrent is undefined.
  • Loading branch information
feross committed May 29, 2016
commit 78cd54797310f3b3993425019baba0dd68ed4b23
@@ -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
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.