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:
authorFeross Aboukhadijeh <feross@feross.org>2021-01-29 04:03:45 +0300
committerFeross Aboukhadijeh <feross@feross.org>2021-01-29 04:03:45 +0300
commit85dad90d30208ef788e691456cbf4319616bc6a0 (patch)
tree38c7910eb42b084a9a8cd68408abd72a190ec568 /lib
parent3a1ea54f9cfbb7a358ef6f4afb65646a65a1672c (diff)
correctly calculate file downloaded progress
Diffstat (limited to 'lib')
-rw-r--r--lib/file.js7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/file.js b/lib/file.js
index d9a10e0..abd4f5d 100644
--- a/lib/file.js
+++ b/lib/file.js
@@ -60,9 +60,10 @@ class File extends EventEmitter {
}
}
- // We don't know the end offset, so return this.length if it's oversized.
- // e.g. One small file can fit in the middle of a piece.
- return Math.min(downloaded, this.length)
+ const irrelevantLastPieceBytes = pieceLength - ((this.offset + this.length) % pieceLength)
+ downloaded -= irrelevantLastPieceBytes
+
+ return downloaded
}
get progress () {