From 181de232f43941b5ffefbccca78a6076e1e854a9 Mon Sep 17 00:00:00 2001 From: Silarn Date: Mon, 25 Jun 2018 20:50:49 -0500 Subject: Potential fix for corrupted downloads --- src/downloadmanager.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/downloadmanager.cpp') diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index ecbcc03b..6d8658c9 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -1251,6 +1251,7 @@ void DownloadManager::downloadProgress(qint64 bytesReceived, qint64 bytesTotal) try { DownloadInfo *info = findDownload(this->sender(), &index); if (info != nullptr) { + info->m_HasData = true; if (info->m_State == STATE_CANCELING) { setState(info, STATE_CANCELED); } else if (info->m_State == STATE_PAUSING) { @@ -1637,7 +1638,7 @@ void DownloadManager::downloadFinished(int index) if (info != nullptr) { QNetworkReply *reply = info->m_Reply; QByteArray data; - if (reply->isOpen()) { + if (reply->isOpen() && info->m_HasData) { data = reply->readAll(); info->m_Output.write(data); } @@ -1666,7 +1667,7 @@ void DownloadManager::downloadFinished(int index) if (info->m_State == STATE_CANCELING) { setState(info, STATE_CANCELED); } else if (info->m_State == STATE_PAUSING) { - if (info->m_Output.isOpen()) { + if (info->m_Output.isOpen() && info->m_HasData) { info->m_Output.write(info->m_Reply->readAll()); } setState(info, STATE_PAUSED); -- cgit v1.3.1