Torrent list: fix % complete bug
This commit is contained in:
@@ -137,11 +137,12 @@ function renderTorrentDetails (torrent, torrentSummary) {
|
|||||||
} else {
|
} else {
|
||||||
// We do know the files. List them and show download stats for each one
|
// We do know the files. List them and show download stats for each one
|
||||||
var fileRows = torrent.files.map(function (file) {
|
var fileRows = torrent.files.map(function (file) {
|
||||||
var numPieces = 0
|
var numPieces = file._endPiece - file._startPiece + 1
|
||||||
for (var piece = file._startPiece; piece < file._endPiece; piece++) {
|
var numPiecesPresent = 0
|
||||||
if (torrent.bitfield.get(piece)) numPieces++
|
for (var piece = file._startPiece; piece <= file._endPiece; piece++) {
|
||||||
|
if (torrent.bitfield.get(piece)) numPiecesPresent++
|
||||||
}
|
}
|
||||||
var progress = Math.round(100 * numPieces / (file._endPiece - file._startPiece)) + '%'
|
var progress = Math.round(100 * numPiecesPresent / numPieces) + '%'
|
||||||
return hx`
|
return hx`
|
||||||
<tr>
|
<tr>
|
||||||
<td class='col-name'>${file.name}</td>
|
<td class='col-name'>${file.name}</td>
|
||||||
|
|||||||
Reference in New Issue
Block a user