diff options
author | Diego RodrÃguez Baquero <DiegoRBaquero@users.noreply.github.com> | 2016-01-04 08:25:19 +0300 |
---|---|---|
committer | Diego RodrÃguez Baquero <DiegoRBaquero@users.noreply.github.com> | 2016-01-04 08:25:19 +0300 |
commit | a473f29f34f76981a40cf6c64cb54c298939684e (patch) | |
tree | a088f8d603ebf1e8a89eb15eff49223490d8f2d7 /lib | |
parent | fba58b35e91da103bf2c1f22c4d238f003b15fe0 (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.js | 1 |
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 |