mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-22 11:37:56 -04:00
Extracted ContentManager::startDownload()
Extracted from ContentManager::downloadBook() the part that should be executed asynchronously into a new function `ContentManager::startDownload()`.
This commit is contained in:
parent
e00f023599
commit
426f13a915
@ -511,9 +511,23 @@ void ContentManager::downloadBook(const QString &id)
|
|||||||
kiwix::Book book = getRemoteOrLocalBook(id);
|
kiwix::Book book = getRemoteOrLocalBook(id);
|
||||||
const auto downloadPath = getSettingsManager()->getDownloadDir();
|
const auto downloadPath = getSettingsManager()->getDownloadDir();
|
||||||
|
|
||||||
std::string downloadId;
|
|
||||||
try {
|
try {
|
||||||
DownloadManager::checkThatBookCanBeDownloaded(book, downloadPath);
|
DownloadManager::checkThatBookCanBeDownloaded(book, downloadPath);
|
||||||
|
} catch ( const KiwixAppError& err ) {
|
||||||
|
showErrorBox(err, mp_view);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
startDownload(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContentManager::startDownload(QString id)
|
||||||
|
{
|
||||||
|
kiwix::Book book = getRemoteOrLocalBook(id);
|
||||||
|
const auto downloadPath = getSettingsManager()->getDownloadDir();
|
||||||
|
|
||||||
|
std::string downloadId;
|
||||||
|
try {
|
||||||
downloadId = DownloadManager::startDownload(book, downloadPath);
|
downloadId = DownloadManager::startDownload(book, downloadPath);
|
||||||
} catch ( const KiwixAppError& err ) {
|
} catch ( const KiwixAppError& err ) {
|
||||||
showErrorBox(err, mp_view);
|
showErrorBox(err, mp_view);
|
||||||
|
@ -118,6 +118,7 @@ private: // functions
|
|||||||
const kiwix::Book& getRemoteOrLocalBook(const QString &id);
|
const kiwix::Book& getRemoteOrLocalBook(const QString &id);
|
||||||
QString getRemoteLibraryUrl() const;
|
QString getRemoteLibraryUrl() const;
|
||||||
|
|
||||||
|
void startDownload(QString bookId);
|
||||||
void removeDownload(QString bookId);
|
void removeDownload(QString bookId);
|
||||||
void downloadDisappeared(QString bookId);
|
void downloadDisappeared(QString bookId);
|
||||||
void downloadCompleted(QString bookId, QString path);
|
void downloadCompleted(QString bookId, QString path);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user