mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-23 20:20:58 -04:00
Rearranged code in DonwloadState::update()
It's more logical to check for the conditions of a disappeared download first.
This commit is contained in:
parent
c20eedf9f6
commit
e020d52745
@ -36,12 +36,6 @@ QString convertToUnits(QString size)
|
|||||||
bool DownloadState::update(QString id)
|
bool DownloadState::update(QString id)
|
||||||
{
|
{
|
||||||
auto downloadInfos = KiwixApp::instance()->getContentManager()->updateDownloadInfos(id, {"status", "completedLength", "totalLength", "downloadSpeed"});
|
auto downloadInfos = KiwixApp::instance()->getContentManager()->updateDownloadInfos(id, {"status", "completedLength", "totalLength", "downloadSpeed"});
|
||||||
double percent = downloadInfos["completedLength"].toDouble() / downloadInfos["totalLength"].toDouble();
|
|
||||||
percent *= 100;
|
|
||||||
percent = QString::number(percent, 'g', 3).toDouble();
|
|
||||||
auto completedLength = convertToUnits(downloadInfos["completedLength"].toString());
|
|
||||||
auto downloadSpeed = convertToUnits(downloadInfos["downloadSpeed"].toString()) + "/s";
|
|
||||||
m_downloadInfo = {percent, completedLength, downloadSpeed, false};
|
|
||||||
if (!downloadInfos["status"].isValid()) {
|
if (!downloadInfos["status"].isValid()) {
|
||||||
m_downloadUpdateTimer->stop();
|
m_downloadUpdateTimer->stop();
|
||||||
|
|
||||||
@ -53,6 +47,13 @@ bool DownloadState::update(QString id)
|
|||||||
m_downloadInfo = {0, "", "", false};
|
m_downloadInfo = {0, "", "", false};
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double percent = downloadInfos["completedLength"].toDouble() / downloadInfos["totalLength"].toDouble();
|
||||||
|
percent *= 100;
|
||||||
|
percent = QString::number(percent, 'g', 3).toDouble();
|
||||||
|
auto completedLength = convertToUnits(downloadInfos["completedLength"].toString());
|
||||||
|
auto downloadSpeed = convertToUnits(downloadInfos["downloadSpeed"].toString()) + "/s";
|
||||||
|
m_downloadInfo = {percent, completedLength, downloadSpeed, false};
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user