mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-21 02:51:26 -04:00
Bugfix: completed downloads are removed
The commit "Moved download deregistration to ContentManager" introduced a bug - completed downloads were not properly deregistered. Note that a simpler fix by adding a single `m_downloads.remove(bookId);` line in `ContentManager::downloadCompleted()` didn't work (which means that that function is not always called upon download completion). I am not going to investigate that issue now, hoping that it will be automatically resolved once the redesign of download management is finished.
This commit is contained in:
parent
b288f287f2
commit
b112c1b34c
@ -486,7 +486,9 @@ void ContentManager::updateDownload(QString bookId)
|
||||
if ( downloadState && !downloadState->paused ) {
|
||||
// This calls ContentManager::updateDownloadInfos() in a convoluted way
|
||||
// and also has some other side-effects
|
||||
managerModel->updateDownload(bookId);
|
||||
if ( ! managerModel->updateDownload(bookId) ) {
|
||||
m_downloads.remove(bookId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -245,12 +245,12 @@ void ContentManagerModel::updateImage(QString bookId, QString url, QByteArray im
|
||||
emit dataChanged(index, index);
|
||||
}
|
||||
|
||||
void ContentManagerModel::updateDownload(QString bookId)
|
||||
bool ContentManagerModel::updateDownload(QString bookId)
|
||||
{
|
||||
const auto download = m_downloads.value(bookId);
|
||||
|
||||
if ( ! download )
|
||||
return;
|
||||
return true;
|
||||
|
||||
const auto downloadInfos = KiwixApp::instance()->getContentManager()->updateDownloadInfos(bookId, {"status", "completedLength", "totalLength", "downloadSpeed"});
|
||||
const bool downloadStillValid = download->update(downloadInfos);
|
||||
@ -269,8 +269,10 @@ void ContentManagerModel::updateDownload(QString bookId)
|
||||
const QModelIndex newIndex = this->index(row, 5);
|
||||
emit dataChanged(newIndex, newIndex);
|
||||
}
|
||||
return downloadStillValid;
|
||||
}
|
||||
|
||||
|
||||
void ContentManagerModel::pauseDownload(QModelIndex index)
|
||||
{
|
||||
emit dataChanged(index, index);
|
||||
|
@ -50,7 +50,7 @@ public slots:
|
||||
void pauseDownload(QModelIndex index);
|
||||
void resumeDownload(QModelIndex index);
|
||||
void removeDownload(QString bookId);
|
||||
void updateDownload(QString bookId);
|
||||
bool updateDownload(QString bookId);
|
||||
|
||||
protected: // functions
|
||||
bool canFetchMore(const QModelIndex &parent) const override;
|
||||
|
Loading…
x
Reference in New Issue
Block a user