DownloadManager::startDownload()

This commit is contained in:
Veloman Yunkan 2024-05-23 14:02:25 +04:00 committed by Kelson
parent f0e91f11f9
commit b5e3c30d46
3 changed files with 14 additions and 6 deletions

View File

@ -622,12 +622,7 @@ std::string ContentManager::startDownload(const kiwix::Book& book)
auto downloadPath = getSettingsManager()->getDownloadDir();
checkThatBookCanBeSaved(book, downloadPath);
typedef std::vector<std::pair<std::string, std::string>> 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)

View File

@ -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<std::pair<std::string, std::string>> 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();

View File

@ -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);