From 323a2635c00ea9b6401a8c1842191377e0b6896b Mon Sep 17 00:00:00 2001 From: MaysWind Date: Tue, 28 Jun 2016 21:58:51 +0800 Subject: [PATCH] fix bug --- src/scripts/services/aria2TaskService.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/scripts/services/aria2TaskService.js b/src/scripts/services/aria2TaskService.js index 21af9e0..d3089dd 100644 --- a/src/scripts/services/aria2TaskService.js +++ b/src/scripts/services/aria2TaskService.js @@ -242,17 +242,25 @@ if (response.success) { var peers = response.data; + var localTaskCompletedPieces = getPieceStatus(task.bitfield, task.numPieces); + var localTaskCompletedPieceCount = ariaNgCommonService.countArray(localTaskCompletedPieces, true); + var localTaskCompletedPercent = task.completePercent; for (var i = 0; i < peers.length; i++) { var peer = peers[i]; var upstreamToSpeed = peer.uploadSpeed; var downstreamFromSpeed = peer.downloadSpeed; var completedPieces = getPieceStatus(peer.bitfield, task.numPieces); + var completedPieceCount = ariaNgCommonService.countArray(completedPieces, true); peer.name = peer.ip + ':' + peer.port; - peer.completePercent = ariaNgCommonService.countArray(completedPieces, true) / task.numPieces * 100; + peer.completePercent = completedPieceCount / task.numPieces * 100; peer.downloadSpeed = upstreamToSpeed; peer.uploadSpeed = downstreamFromSpeed; + + if (completedPieceCount == localTaskCompletedPieceCount && peer.completePercent != localTaskCompletedPercent) { + peer.completePercent = localTaskCompletedPercent; + } } if (includeLocal) {