mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-21 02:51:26 -04:00
DownloadManager::updateDownload(bookId)
This commit is contained in:
parent
abd3ed5225
commit
03c45e814b
@ -95,7 +95,9 @@ void DownloadManager::startDownloadUpdaterThread()
|
||||
|
||||
mp_downloadUpdaterThread = QThread::create([=]() {
|
||||
while ( mp_downloadUpdaterThread != nullptr ) {
|
||||
updateDownloads();
|
||||
for ( const auto& bookId : m_downloads.keys() ) {
|
||||
updateDownload(bookId);
|
||||
}
|
||||
QThread::msleep(1000);
|
||||
}
|
||||
});
|
||||
@ -114,19 +116,17 @@ void DownloadManager::restoreDownloads()
|
||||
}
|
||||
}
|
||||
|
||||
void DownloadManager::updateDownloads()
|
||||
void DownloadManager::updateDownload(QString bookId)
|
||||
{
|
||||
DownloadInfo downloadInfo;
|
||||
for ( const auto& bookId : m_downloads.keys() ) {
|
||||
try {
|
||||
downloadInfo = getDownloadInfo(bookId);
|
||||
} catch ( ... ) {
|
||||
emit downloadDisappeared(bookId);
|
||||
continue;
|
||||
}
|
||||
|
||||
emit downloadUpdated(bookId, downloadInfo);
|
||||
try {
|
||||
downloadInfo = getDownloadInfo(bookId);
|
||||
} catch ( ... ) {
|
||||
emit downloadDisappeared(bookId);
|
||||
return;
|
||||
}
|
||||
|
||||
emit downloadUpdated(bookId, downloadInfo);
|
||||
}
|
||||
|
||||
namespace
|
||||
|
@ -97,7 +97,6 @@ public: // functions
|
||||
|
||||
DownloadInfo getDownloadInfo(QString bookId) const;
|
||||
void restoreDownloads();
|
||||
void updateDownloads();
|
||||
|
||||
// returns the download id
|
||||
std::string startDownload(const kiwix::Book& book, const QString& downloadDirPath);
|
||||
@ -115,6 +114,9 @@ signals:
|
||||
void downloadUpdated(QString bookId, const DownloadInfo& );
|
||||
void downloadDisappeared(QString bookId);
|
||||
|
||||
private: // functions
|
||||
void updateDownload(QString bookId);
|
||||
|
||||
private: // data
|
||||
const Library* const mp_library;
|
||||
kiwix::Downloader* const mp_downloader;
|
||||
|
Loading…
x
Reference in New Issue
Block a user