From 9831fec046e7440f016ae6287857fc81004226dc Mon Sep 17 00:00:00 2001
From: iplaycello <275392897+iplaycello@users.noreply.github.com>
Date: Sun, 12 Apr 2026 10:14:23 +0800
Subject: [PATCH] Truncate (floor) progress and availability instead of
rounding up
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Availability of 0.999 rounded to 1.00 is misleading — in torrents,
anything below 1.0 means the complete file cannot be assembled from
available peers. Progress similarly should not round up to 100% when
the download is not yet complete.
---
app/torrent/[hash].tsx | 6 +++---
app/torrent/files.tsx | 2 +-
components/TorrentCard.tsx | 8 ++++----
components/TorrentDetails.tsx | 6 +++---
4 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/app/torrent/[hash].tsx b/app/torrent/[hash].tsx
index 4a87e37..a4a4f73 100644
--- a/app/torrent/[hash].tsx
+++ b/app/torrent/[hash].tsx
@@ -879,7 +879,7 @@ export default function TorrentDetail() {
{torrent.eta > 0 && torrent.eta < 8640000
? t('torrentDetail.remaining', { time: formatTime(torrent.eta) })
- : progress >= 100
+ : torrent.progress >= 1
? t('torrentDetail.complete')
: '∞'}
@@ -967,7 +967,7 @@ export default function TorrentDetail() {
`${torrent.num_leechs || 0} / ${torrent.num_incomplete || 0}`,
handleOpenPeerDetails,
),
- staticRow(t('torrentDetail.availability'), torrent.availability ? torrent.availability.toFixed(2) : '0.00'),
+ staticRow(t('torrentDetail.availability'), torrent.availability ? (Math.floor(torrent.availability * 1000) / 1000).toFixed(3) : '0.000'),
])}
@@ -1121,7 +1121,7 @@ export default function TorrentDetail() {
style={[styles.peerRow, { borderBottomColor: colors.surfaceOutline }]}
>
- {(p.progress * 100).toFixed(1)}%
+ {(Math.floor(p.progress * 1000) / 10).toFixed(1)}%
diff --git a/app/torrent/files.tsx b/app/torrent/files.tsx
index b8aef7b..bc38d21 100644
--- a/app/torrent/files.tsx
+++ b/app/torrent/files.tsx
@@ -525,7 +525,7 @@ export default function TorrentFilesScreen() {
•
- {(file.progress * 100).toFixed(1)}%
+ {(Math.floor(file.progress * 1000) / 10).toFixed(1)}%
diff --git a/components/TorrentCard.tsx b/components/TorrentCard.tsx
index ec687ae..7e6e998 100644
--- a/components/TorrentCard.tsx
+++ b/components/TorrentCard.tsx
@@ -108,7 +108,7 @@ function TorrentCardInner({
const statusLine = [
stateLabel,
speedText,
- `${progress.toFixed(0)}%`,
+ `${Math.floor(progress)}%`,
hasEta ? formatTime(torrent.eta) : null,
].filter(Boolean).join(' · ');
@@ -191,7 +191,7 @@ function TorrentCardInner({
{show('progress') && (
)}
{show('dlSpeed') && dlspeed > 0 && (
@@ -236,10 +236,10 @@ function TorrentCardInner({
value={formatSize(torrent.uploaded)}
/>
)}
- {show('availability') && torrent.availability > 0 && torrent.availability < 1 && (
+ {show('availability') && torrent.availability > 0 && (
)}
{show('seedingTime') && torrent.seeding_time > 0 && (
diff --git a/components/TorrentDetails.tsx b/components/TorrentDetails.tsx
index 2586877..67905e5 100644
--- a/components/TorrentDetails.tsx
+++ b/components/TorrentDetails.tsx
@@ -1124,7 +1124,7 @@ export function TorrentDetails({
style={[styles.peerRow, { borderBottomColor: colors.surfaceOutline }]}
>
- {(p.progress * 100).toFixed(1)}%
+ {(Math.floor(p.progress * 1000) / 10).toFixed(1)}%
@@ -1151,7 +1151,7 @@ export function TorrentDetails({
{t('torrentDetail.generalInformation')}
-
+
@@ -1402,7 +1402,7 @@ export function TorrentDetails({
{formatSize(file.size)}
- {(file.progress * 100).toFixed(1)}%
+ {(Math.floor(file.progress * 1000) / 10).toFixed(1)}%