mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-21 02:51:26 -04:00
DownloadManager::checkThatBookCanBeDownloaded()
Separated checks that can be performed early (independent of aria2c services). When the download initiation is converted to a 2-stage procedure (similar to how it was done for pausing/resuming/cancelling a download) those checks better be performed synchronously in the main thread.
This commit is contained in:
parent
b753a47fbc
commit
e00f023599
@ -513,6 +513,7 @@ void ContentManager::downloadBook(const QString &id)
|
||||
|
||||
std::string downloadId;
|
||||
try {
|
||||
DownloadManager::checkThatBookCanBeDownloaded(book, downloadPath);
|
||||
downloadId = DownloadManager::startDownload(book, downloadPath);
|
||||
} catch ( const KiwixAppError& err ) {
|
||||
showErrorBox(err, mp_view);
|
||||
|
@ -257,13 +257,16 @@ void checkThatBookCanBeSaved(const kiwix::Book& book, QString targetDir)
|
||||
} // unnamed namespace
|
||||
|
||||
|
||||
std::string DownloadManager::startDownload(const kiwix::Book& book, const QString& downloadDirPath)
|
||||
void DownloadManager::checkThatBookCanBeDownloaded(const kiwix::Book& book, const QString& downloadDirPath)
|
||||
{
|
||||
if ( ! DownloadManager::downloadingFunctionalityAvailable() )
|
||||
throwDownloadUnavailableError();
|
||||
|
||||
checkThatBookCanBeSaved(book, downloadDirPath);
|
||||
}
|
||||
|
||||
std::string DownloadManager::startDownload(const kiwix::Book& book, const QString& downloadDirPath)
|
||||
{
|
||||
typedef std::vector<std::pair<std::string, std::string>> DownloadOptions;
|
||||
|
||||
const std::string& url = book.getUrl();
|
||||
|
@ -156,6 +156,10 @@ public: // functions
|
||||
|
||||
void addRequest(Action action, QString bookId);
|
||||
|
||||
// Throws a KiwixAppError in case of any foreseeable problem preventing a
|
||||
// successful download
|
||||
void checkThatBookCanBeDownloaded(const kiwix::Book& book, const QString& downloadDirPath);
|
||||
|
||||
// returns the download id
|
||||
std::string startDownload(const kiwix::Book& book, const QString& downloadDirPath);
|
||||
void removeDownload(QString bookId);
|
||||
|
Loading…
x
Reference in New Issue
Block a user