From c9748e7e31dffc1a35510abdf82c5c76a4d77325 Mon Sep 17 00:00:00 2001 From: Jesse Chan Date: Thu, 26 Nov 2020 23:49:31 +0800 Subject: [PATCH] server: don't truncate percentCompleted to integer It is frontend's job to handle this. --- server/services/Transmission/clientGatewayService.ts | 6 +++--- server/services/qBittorrent/clientGatewayService.ts | 6 +++--- server/services/rTorrent/clientGatewayService.ts | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/server/services/Transmission/clientGatewayService.ts b/server/services/Transmission/clientGatewayService.ts index 6d6603b8..5ccbec78 100644 --- a/server/services/Transmission/clientGatewayService.ts +++ b/server/services/Transmission/clientGatewayService.ts @@ -139,7 +139,7 @@ class TransmissionClientGatewayService extends ClientGatewayService { index, path: file.name, filename: file.name.split('/').pop() as string, - percentComplete: Math.trunc(file.bytesCompleted / file.length), + percentComplete: file.bytesCompleted / file.length, priority, sizeBytes: file.length, }; @@ -165,7 +165,7 @@ class TransmissionClientGatewayService extends ClientGatewayService { address: peer.address, country: geoip.lookup(peer.address)?.country || '', clientVersion: peer.clientName, - completedPercent: Math.trunc(peer.progress * 100), + completedPercent: peer.progress * 100, downloadRate: peer.rateToClient, uploadRate: peer.rateToPeer, isEncrypted: peer.isEncrypted, @@ -332,7 +332,7 @@ class TransmissionClientGatewayService extends ClientGatewayService { {}, ...(await Promise.all( torrents.map(async (torrent) => { - const percentComplete = Math.trunc((torrent.haveValid / torrent.totalSize) * 100); + const percentComplete = (torrent.haveValid / torrent.totalSize) * 100; const ratio = torrent.downloadedEver === 0 ? -1 : torrent.uploadedEver / torrent.downloadedEver; const trackerURIs = getDomainsFromURLs(torrent.trackers.map((tracker) => tracker.announce)); const status = torrentPropertiesUtil.getTorrentStatus(torrent); diff --git a/server/services/qBittorrent/clientGatewayService.ts b/server/services/qBittorrent/clientGatewayService.ts index 4e0c7730..b300a734 100644 --- a/server/services/qBittorrent/clientGatewayService.ts +++ b/server/services/qBittorrent/clientGatewayService.ts @@ -94,7 +94,7 @@ class QBittorrentClientGatewayService extends ClientGatewayService { index, path: content.name, filename: content.name.split('/').pop() || '', - percentComplete: Math.trunc(content.progress * 100), + percentComplete: content.progress * 100, priority, sizeBytes: content.size, }; @@ -120,7 +120,7 @@ class QBittorrentClientGatewayService extends ClientGatewayService { address: peer.ip, country: peer.country_code, clientVersion: peer.client, - completedPercent: Math.trunc(peer.progress * 100), + completedPercent: peer.progress * 100, downloadRate: peer.dl_speed, uploadRate: peer.up_speed, isEncrypted: properties.isEncrypted, @@ -277,7 +277,7 @@ class QBittorrentClientGatewayService extends ClientGatewayService { name: info.name, peersConnected: info.num_leechs, peersTotal: info.num_incomplete, - percentComplete: Math.trunc(info.progress * 100), + percentComplete: info.progress * 100, priority: 1, ratio: info.ratio, seedsConnected: info.num_seeds, diff --git a/server/services/rTorrent/clientGatewayService.ts b/server/services/rTorrent/clientGatewayService.ts index 02f69a00..bd4fbeb7 100644 --- a/server/services/rTorrent/clientGatewayService.ts +++ b/server/services/rTorrent/clientGatewayService.ts @@ -196,7 +196,7 @@ class RTorrentClientGatewayService extends ClientGatewayService { index, path: content.path, filename: content.path.split('/').pop() || '', - percentComplete: Math.trunc((content.completedChunks / content.sizeChunks) * 100), + percentComplete: (content.completedChunks / content.sizeChunks) * 100, priority: content.priority, sizeBytes: content.sizeBytes, };