Got rid of a ContentManager::downloadBook() overload

This commit is contained in:
Veloman Yunkan 2024-06-07 17:19:50 +04:00 committed by Kelson
parent d0a8f2519b
commit b753a47fbc
2 changed files with 12 additions and 19 deletions

View File

@ -511,18 +511,21 @@ void ContentManager::downloadBook(const QString &id)
kiwix::Book book = getRemoteOrLocalBook(id);
const auto downloadPath = getSettingsManager()->getDownloadDir();
try
{
downloadBook(book, downloadPath);
std::string downloadId;
try {
downloadId = DownloadManager::startDownload(book, downloadPath);
} catch ( const KiwixAppError& err ) {
showErrorBox(err, mp_view);
return;
}
book.setDownloadId(downloadId);
mp_library->addBookBeingDownloaded(book, downloadPath);
mp_library->save();
const auto downloadState = DownloadManager::getDownloadState(id);
managerModel->setDownloadState(id, downloadState);
emit(oneBookChanged(id));
}
catch ( const KiwixAppError& err )
{
showErrorBox(err, mp_view);
}
}
const kiwix::Book& ContentManager::getRemoteOrLocalBook(const QString &id)
{
@ -542,15 +545,6 @@ QString ContentManager::getRemoteLibraryUrl() const
: "http://" + host + ":" + QString::number(port);
}
void ContentManager::downloadBook(kiwix::Book book, const QString& downloadPath)
{
const std::string downloadId = DownloadManager::startDownload(book, downloadPath);
book.setDownloadId(downloadId);
mp_library->addBookBeingDownloaded(book, downloadPath);
mp_library->save();
}
static const char MSG_FOR_PREVENTED_RMSTAR_OPERATION[] = R"(
BUG: Errare humanum est.
BUG: Kiwix developers are human, but we try to ensure that our mistakes

View File

@ -121,7 +121,6 @@ private: // functions
void removeDownload(QString bookId);
void downloadDisappeared(QString bookId);
void downloadCompleted(QString bookId, QString path);
void downloadBook(kiwix::Book book, const QString& downloadPath);
private: // data
Library* mp_library;