diff --git a/src/contentmanager.cpp b/src/contentmanager.cpp index 4178b47..065a8b1 100644 --- a/src/contentmanager.cpp +++ b/src/contentmanager.cpp @@ -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); diff --git a/src/downloadmanagement.cpp b/src/downloadmanagement.cpp index 2be8c8b..20fbab0 100644 --- a/src/downloadmanagement.cpp +++ b/src/downloadmanagement.cpp @@ -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> DownloadOptions; const std::string& url = book.getUrl(); diff --git a/src/downloadmanagement.h b/src/downloadmanagement.h index 0509b78..07d0e73 100644 --- a/src/downloadmanagement.h +++ b/src/downloadmanagement.h @@ -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);