mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-22 11:37:56 -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([=]() {
|
mp_downloadUpdaterThread = QThread::create([=]() {
|
||||||
while ( mp_downloadUpdaterThread != nullptr ) {
|
while ( mp_downloadUpdaterThread != nullptr ) {
|
||||||
updateDownloads();
|
for ( const auto& bookId : m_downloads.keys() ) {
|
||||||
|
updateDownload(bookId);
|
||||||
|
}
|
||||||
QThread::msleep(1000);
|
QThread::msleep(1000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -114,19 +116,17 @@ void DownloadManager::restoreDownloads()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadManager::updateDownloads()
|
void DownloadManager::updateDownload(QString bookId)
|
||||||
{
|
{
|
||||||
DownloadInfo downloadInfo;
|
DownloadInfo downloadInfo;
|
||||||
for ( const auto& bookId : m_downloads.keys() ) {
|
try {
|
||||||
try {
|
downloadInfo = getDownloadInfo(bookId);
|
||||||
downloadInfo = getDownloadInfo(bookId);
|
} catch ( ... ) {
|
||||||
} catch ( ... ) {
|
emit downloadDisappeared(bookId);
|
||||||
emit downloadDisappeared(bookId);
|
return;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
emit downloadUpdated(bookId, downloadInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emit downloadUpdated(bookId, downloadInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
@ -97,7 +97,6 @@ public: // functions
|
|||||||
|
|
||||||
DownloadInfo getDownloadInfo(QString bookId) const;
|
DownloadInfo getDownloadInfo(QString bookId) const;
|
||||||
void restoreDownloads();
|
void restoreDownloads();
|
||||||
void updateDownloads();
|
|
||||||
|
|
||||||
// returns the download id
|
// returns the download id
|
||||||
std::string startDownload(const kiwix::Book& book, const QString& downloadDirPath);
|
std::string startDownload(const kiwix::Book& book, const QString& downloadDirPath);
|
||||||
@ -115,6 +114,9 @@ signals:
|
|||||||
void downloadUpdated(QString bookId, const DownloadInfo& );
|
void downloadUpdated(QString bookId, const DownloadInfo& );
|
||||||
void downloadDisappeared(QString bookId);
|
void downloadDisappeared(QString bookId);
|
||||||
|
|
||||||
|
private: // functions
|
||||||
|
void updateDownload(QString bookId);
|
||||||
|
|
||||||
private: // data
|
private: // data
|
||||||
const Library* const mp_library;
|
const Library* const mp_library;
|
||||||
kiwix::Downloader* const mp_downloader;
|
kiwix::Downloader* const mp_downloader;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user