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
path: root/lib
diff options
context:
space:
mode:
authorDiego Rodríguez Baquero <DiegoRBaquero@users.noreply.github.com>2016-01-04 08:25:19 +0300
committerDiego Rodríguez Baquero <DiegoRBaquero@users.noreply.github.com>2016-01-04 08:25:19 +0300
commita473f29f34f76981a40cf6c64cb54c298939684e (patch)
treea088f8d603ebf1e8a89eb15eff49223490d8f2d7 /lib
parentfba58b35e91da103bf2c1f22c4d238f003b15fe0 (diff)
Fix downloaded property access
When bitfield is not yet created, accessing downloaded property will throw an error.
Diffstat (limited to 'lib')
-rw-r--r--lib/torrent.js1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/torrent.js b/lib/torrent.js
index 0ed1fa5..0beedc1 100644
--- a/lib/torrent.js
+++ b/lib/torrent.js
@@ -105,6 +105,7 @@ Object.defineProperty(Torrent.prototype, 'timeRemaining', {
// Bytes completed (excluding invalid data)
Object.defineProperty(Torrent.prototype, 'downloaded', {
get: function () {
+ if (!this.bitfield) return 0
var downloaded = 0
for (var index = 0, len = this.pieces.length; index < len; ++index) {
if (this.bitfield.get(index)) { // verified data