From 32e3c743f7996d299489eccf92c789b812d4a7c0 Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Mon, 12 Feb 2024 18:35:44 +0400 Subject: [PATCH] Preparing to make updateDownload() a slot ... that can be called from a worker thread. --- src/contentmanager.cpp | 8 ++++---- src/contentmanager.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/contentmanager.cpp b/src/contentmanager.cpp index c4761fd..21de2e1 100644 --- a/src/contentmanager.cpp +++ b/src/contentmanager.cpp @@ -477,12 +477,10 @@ DownloadInfo ContentManager::getDownloadInfo(QString bookId) const }; } -void ContentManager::updateDownload(QString bookId) +void ContentManager::updateDownload(QString bookId, const DownloadInfo& downloadInfo) { const auto downloadState = m_downloads.value(bookId); if ( downloadState && !downloadState->paused ) { - const auto downloadInfo = getDownloadInfo(bookId); - if ( downloadInfo.isEmpty() ) { downloadDisappeared(bookId); } else if ( downloadInfo["status"] == "completed" ) { @@ -497,7 +495,9 @@ void ContentManager::updateDownload(QString bookId) void ContentManager::updateDownloads() { for ( const auto& bookId : m_downloads.keys() ) { - updateDownload(bookId); + const auto downloadInfo = getDownloadInfo(bookId); + + updateDownload(bookId, downloadInfo); } } diff --git a/src/contentmanager.h b/src/contentmanager.h index 0d3d067..f947a69 100644 --- a/src/contentmanager.h +++ b/src/contentmanager.h @@ -83,7 +83,7 @@ private: // functions const kiwix::Book& getRemoteOrLocalBook(const QString &id); std::string startDownload(const kiwix::Book& book); - void updateDownload(QString bookId); + void updateDownload(QString bookId, const DownloadInfo& downloadInfo); void removeDownload(QString bookId); void downloadStarted(const kiwix::Book& book, const std::string& downloadId); void downloadDisappeared(QString bookId);