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:
Diffstat (limited to 'lib/torrent.js')
-rw-r--r--lib/torrent.js7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/torrent.js b/lib/torrent.js
index f60d459..62fa016 100644
--- a/lib/torrent.js
+++ b/lib/torrent.js
@@ -1269,7 +1269,7 @@ class Torrent extends EventEmitter {
const self = this
if (typeof window !== 'undefined' && typeof window.requestIdleCallback === 'function') {
- window.requestIdleCallback(function () { self._updateWire(wire) }, { timeout: 250 })
+ window.requestIdleCallback(() => { self._updateWire(wire) }, { timeout: 250 })
} else {
self._updateWire(wire)
}
@@ -1677,8 +1677,8 @@ class Torrent extends EventEmitter {
// is the torrent done? (if all current selections are satisfied, or there are
// no selections, then torrent is done)
let done = true
- for (let i = 0; i < this._selections.length; i++) {
- const selection = this._selections[i]
+
+ for (const selection of this._selections) {
for (let piece = selection.from; piece <= selection.to; piece++) {
if (!this.bitfield.get(piece)) {
done = false
@@ -1687,6 +1687,7 @@ class Torrent extends EventEmitter {
}
if (!done) break
}
+
if (!this.done && done) {
this.done = true
this._debug(`torrent done: ${this.infoHash}`)