From b5e3c30d465c52ef256f0b57e0513ceb20c632c2 Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Thu, 23 May 2024 14:02:25 +0400 Subject: [PATCH] DownloadManager::startDownload() --- src/contentmanager.cpp | 7 +------ src/downloadmanagement.cpp | 10 ++++++++++ src/downloadmanagement.h | 3 +++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/contentmanager.cpp b/src/contentmanager.cpp index 12b5f87..ce24378 100644 --- a/src/contentmanager.cpp +++ b/src/contentmanager.cpp @@ -622,12 +622,7 @@ std::string ContentManager::startDownload(const kiwix::Book& book) auto downloadPath = getSettingsManager()->getDownloadDir(); checkThatBookCanBeSaved(book, downloadPath); - typedef std::vector> DownloadOptions; - - const DownloadOptions downloadOptions{{"dir", downloadPath.toStdString()}}; - - const auto d = mp_downloader->startDownload(book.getUrl(), downloadOptions); - return d->getDid(); + return DownloadManager::startDownload(book.getUrl(), downloadPath.toStdString()); } void ContentManager::downloadBook(const QString &id) diff --git a/src/downloadmanagement.cpp b/src/downloadmanagement.cpp index 417e487..ddc5201 100644 --- a/src/downloadmanagement.cpp +++ b/src/downloadmanagement.cpp @@ -104,6 +104,16 @@ DownloadInfo DownloadManager::getDownloadInfo(QString bookId) const }; } +std::string DownloadManager::startDownload(const std::string& url, const std::string& downloadDirPath) +{ + typedef std::vector> DownloadOptions; + + const DownloadOptions downloadOptions{{"dir", downloadDirPath}}; + + const auto d = mp_downloader->startDownload(url, downloadOptions); + return d->getDid(); +} + void DownloadManager::pauseDownload(const QString& bookId) { const auto downloadId = mp_library->getBookById(bookId).getDownloadId(); diff --git a/src/downloadmanagement.h b/src/downloadmanagement.h index 0f1a257..e55d563 100644 --- a/src/downloadmanagement.h +++ b/src/downloadmanagement.h @@ -73,6 +73,9 @@ public: // functions DownloadInfo getDownloadInfo(QString bookId) const; void restoreDownloads(); void updateDownloads(); + + // returns the download id + std::string startDownload(const std::string& url, const std::string& downloadDirPath); void pauseDownload(const QString& bookId); void resumeDownload(const QString& bookId);