Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Chevers Williams <wdc@student.unimelb.edu.au>2017-07-29 15:51:49 +0300
committerDavid Chevers Williams <wdc@student.unimelb.edu.au>2017-07-29 16:21:52 +0300
commitc04a4167250bfa236f78e91352867aa3c6c9c33f (patch)
treed8fef4d053c1257ba42780d52c8b79405e8023dd /lib/file-stream.js
parentae9e5d605f17e1ab8503def1542b964b189e9817 (diff)
Raise error when streaming from a removed torrent
In Node.js 8.2.1, when a torrent is removed while a file from it is being streamed, file-stream.js exits, crashing Node with a TypeError: VM535 file-stream.js:64 Uncaught TypeError: Cannot read property 'get' of null This patch checks whether the torrent has been marked as destroyed, and if so, raises the error to the file stream.
Diffstat (limited to 'lib/file-stream.js')
-rw-r--r--lib/file-stream.js2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/file-stream.js b/lib/file-stream.js
index 508f358..11514b4 100644
--- a/lib/file-stream.js
+++ b/lib/file-stream.js
@@ -56,6 +56,8 @@ FileStream.prototype._notify = function () {
if (self._notifying) return
self._notifying = true
+ if (self._torrent.destroyed) return self._destroy(new Error('Torrent removed'))
+
var p = self._piece
self._torrent.store.get(p, function (err, buffer) {
self._notifying = false