diff --git a/src/rownode.cpp b/src/rownode.cpp index 2a5c15f..2559b99 100644 --- a/src/rownode.cpp +++ b/src/rownode.cpp @@ -36,12 +36,6 @@ QString convertToUnits(QString size) bool DownloadState::update(QString id) { 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()) { m_downloadUpdateTimer->stop(); @@ -53,6 +47,13 @@ bool DownloadState::update(QString id) m_downloadInfo = {0, "", "", 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; }