From b6aa12b323a81f4ac8e1bb76c2fea780a1698d97 Mon Sep 17 00:00:00 2001 From: Al12rs Date: Tue, 19 Jun 2018 23:13:06 +0200 Subject: Fix for downloads getting insta-completed if there isn't enough bandwidth for them to procede. Now they will instead remain in the download state and continue once the bandwidth is available. There is much room for improvement here but for now I guess this will avoid MO simply stopping the download. --- src/downloadmanager.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/downloadmanager.cpp') diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 0341152a..6ed93ec1 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -785,7 +785,13 @@ void DownloadManager::resumeDownloadInt(int index) return; } - if (info->isPausedState()) { + if (info->isPausedState() || info->m_State == STATE_PAUSING) { + if (info->m_State == STATE_PAUSING) { + if (info->m_Output.isOpen()) { + info->m_Output.write(info->m_Reply->readAll()); + setState(info, STATE_PAUSED); + } + } if ((info->m_Urls.size() == 0) || ((info->m_Urls.size() == 1) && (info->m_Urls[0].size() == 0))) { emit showMessage(tr("No known download urls. Sorry, this download can't be resumed.")); @@ -1662,6 +1668,7 @@ void DownloadManager::downloadFinished(int index) } else if (info->m_State == STATE_PAUSING) { if (info->m_Output.isOpen()) { info->m_Output.write(info->m_Reply->readAll()); + setState(info, STATE_PAUSED); } } @@ -1673,7 +1680,7 @@ void DownloadManager::downloadFinished(int index) if (error) emit showMessage(tr("We were unable to download the file due to errors after four retries. There may be an issue with the Nexus servers.")); emit update(-1); - } else if (info->isPausedState()) { + } else if (info->isPausedState() || info->m_State == STATE_PAUSING) { info->m_Output.close(); createMetaFile(info); emit update(index); -- cgit v1.3.1