mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-21 11:08:54 -04:00
Got rid of ContentManager::updateDownloadInfo()
... by inlining it into ContentManager::updateDownload()
This commit is contained in:
parent
d089dced05
commit
6f781a8e0e
@ -464,27 +464,18 @@ DownloadInfo ContentManager::getDownloadInfo(QString bookId, const QStringList &
|
||||
return values;
|
||||
}
|
||||
|
||||
DownloadInfo ContentManager::updateDownloadInfos(QString bookId, QStringList keys)
|
||||
{
|
||||
if ( !keys.contains("status") ) keys.append("status");
|
||||
if ( !keys.contains("path") ) keys.append("path");
|
||||
|
||||
const DownloadInfo result = getDownloadInfo(bookId, keys);
|
||||
|
||||
if ( result.isEmpty() ) {
|
||||
downloadCancelled(bookId);
|
||||
} else if ( result["status"] == "completed" ) {
|
||||
downloadCompleted(bookId, result["path"].toString());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void ContentManager::updateDownload(QString bookId)
|
||||
{
|
||||
const auto downloadState = m_downloads.value(bookId);
|
||||
if ( downloadState && !downloadState->paused ) {
|
||||
const auto downloadInfo = updateDownloadInfos(bookId, {"status", "completedLength", "totalLength", "downloadSpeed"});
|
||||
const auto downloadInfo = getDownloadInfo(bookId, {"status", "completedLength", "totalLength", "downloadSpeed", "path"});
|
||||
|
||||
if ( downloadInfo.isEmpty() ) {
|
||||
downloadCancelled(bookId);
|
||||
} else if ( downloadInfo["status"] == "completed" ) {
|
||||
downloadCompleted(bookId, downloadInfo["path"].toString());
|
||||
}
|
||||
|
||||
const bool downloadStillValid = downloadState->update(downloadInfo);
|
||||
if ( ! downloadStillValid ) {
|
||||
m_downloads.remove(bookId);
|
||||
|
@ -49,7 +49,6 @@ public slots:
|
||||
QStringList getTranslations(const QStringList &keys);
|
||||
BookInfo getBookInfos(QString id, const QStringList &keys);
|
||||
void openBook(const QString& id);
|
||||
DownloadInfo updateDownloadInfos(QString bookId, QStringList keys);
|
||||
void downloadBook(const QString& id);
|
||||
void downloadBook(const QString& id, QModelIndex index);
|
||||
void updateLibrary();
|
||||
|
Loading…
x
Reference in New Issue
Block a user