diff --git a/src/contentmanager.cpp b/src/contentmanager.cpp index 3de9736..0f6c6bb 100644 --- a/src/contentmanager.cpp +++ b/src/contentmanager.cpp @@ -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); diff --git a/src/contentmanager.h b/src/contentmanager.h index d128c22..585b181 100644 --- a/src/contentmanager.h +++ b/src/contentmanager.h @@ -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();