Skip to content

Commit 74c2a5d

Browse files
authored
Update download progress calculation in CVersionUpdater (#2876)
1 parent 0454e3c commit 74c2a5d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Client/core/CVersionUpdater.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2768,8 +2768,11 @@ int CVersionUpdater::_PollDownload()
27682768
return RES_OK;
27692769
}
27702770
if (m_JobInfo.bShowDownloadPercent)
2771-
GetQuestionBox().SetMessage(
2772-
SString(_("%3d %% completed"), Round(m_JobInfo.uiBytesDownloaded * 100.f / std::max<float>(1, m_JobInfo.iFilesize))));
2771+
{
2772+
const bool bIsDownloadedSizeRight = m_JobInfo.uiBytesDownloaded > 0 && m_JobInfo.iFilesize >= m_JobInfo.uiBytesDownloaded;
2773+
const float fDownloadedPercent = bIsDownloadedSizeRight ? Round(m_JobInfo.uiBytesDownloaded / m_JobInfo.iFilesize * 100.f) : 0;
2774+
GetQuestionBox().SetMessage(SString(_("%3d %% completed"), fDownloadedPercent));
2775+
}
27732776
if (m_JobInfo.iIdleTime > 1000 && m_JobInfo.iIdleTimeLeft > 500)
27742777
GetQuestionBox().AppendMessage(SString(_("\n\nWaiting for response - %-3d"), m_JobInfo.iIdleTimeLeft / 1000));
27752778
else

0 commit comments

Comments
 (0)