Skip to content

Commit

Permalink
Merge pull request #342 from Modorganizer2/Develop
Browse files Browse the repository at this point in the history
Fix an issue with resuming a completed download
  • Loading branch information
Silarn authored May 9, 2018
2 parents 5e6bb0a + 11aa955 commit 26b946a
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/downloadmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,10 @@ void DownloadManager::startDownload(QNetworkReply *reply, DownloadInfo *newDownl

QCoreApplication::processEvents();

if (newDownload->m_State != STATE_DOWNLOADING && reply->isFinished()) {
if (newDownload->m_State != STATE_DOWNLOADING &&
newDownload->m_State != STATE_READY &&
newDownload->m_State != STATE_FETCHINGMODINFO &&
reply->isFinished()) {
downloadFinished(indexByName(newDownload->m_FileName));
return;
}
Expand Down Expand Up @@ -499,7 +502,7 @@ void DownloadManager::addNXMDownload(const QString &url)
for (DownloadInfo *download : m_ActiveDownloads) {
if (download->m_FileInfo->modID == nxmInfo.modId() && download->m_FileInfo->fileID == nxmInfo.fileId()) {
if (download->m_State == STATE_DOWNLOADING || download->m_State == STATE_PAUSED || download->m_State == STATE_STARTED) {
qDebug("download requested is already started (mod: %s, file: %s)", qPrintable(download->m_FileInfo->modID),
qDebug("download requested is already started (mod: %s, file: %s)", qPrintable(QString(download->m_FileInfo->modID)),
qPrintable(download->m_FileInfo->fileName));

QMessageBox::information(nullptr, tr("Already Started"), tr("There is already a download started for this file (mod: %1, file: %2).")
Expand Down Expand Up @@ -690,6 +693,14 @@ void DownloadManager::resumeDownloadInt(int index)
return;
}
DownloadInfo *info = m_ActiveDownloads[index];

// Check for finished download;
if (info->m_TotalSize <= info->m_Output.size()) {
setState(info, STATE_DOWNLOADING);
downloadFinished(index);
return;
}

if (info->isPausedState()) {
if ((info->m_Urls.size() == 0)
|| ((info->m_Urls.size() == 1) && (info->m_Urls[0].size() == 0))) {
Expand Down

0 comments on commit 26b946a

Please sign in to comment.