From 9317c25ecb73c5b0e46fd0656252eef766053682 Mon Sep 17 00:00:00 2001 From: vikas_c <69648303+vikasc28@users.noreply.github.com> Date: Thu, 20 Jun 2024 10:38:55 +0530 Subject: [PATCH] Show download progress for folders with zero byte size as 100 instead of 0 Fixes the download progress calculation for folders with zero size. Previously, the progress would be Zero. Now, folders with zero size show 100% progress. PR #20567. --- src/gui/torrentcontentmodelfolder.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/gui/torrentcontentmodelfolder.cpp b/src/gui/torrentcontentmodelfolder.cpp index abece9c9b..b8a536216 100644 --- a/src/gui/torrentcontentmodelfolder.cpp +++ b/src/gui/torrentcontentmodelfolder.cpp @@ -147,10 +147,19 @@ void TorrentContentModelFolder::recalculateProgress() tRemaining += child->remaining(); } - if (!isRootItem() && (tSize > 0)) + if (!isRootItem()) { - m_progress = tProgress / tSize; - m_remaining = tRemaining; + if (tSize > 0) + { + m_progress = tProgress / tSize; + m_remaining = tRemaining; + } + else + { + m_progress = 1.0; + m_remaining = 0; + } + Q_ASSERT(m_progress <= 1.); } }