From b78444490ccad85bf15e9d5d8ed51cc2ad3fb06b Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 16 Oct 2016 17:29:10 +0200 Subject: [PATCH] Fixed: Infinite loop when HTTP error occurs --HG-- branch : develop --- .../client/ryzom_installer/src/downloader.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/downloader.cpp b/code/ryzom/tools/client/ryzom_installer/src/downloader.cpp index 20a55d278..cdd471cf6 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/downloader.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/downloader.cpp @@ -356,6 +356,8 @@ void CDownloader::onHeadFinished() void CDownloader::onDownloadFinished() { + int status = m_reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); + m_reply->deleteLater(); m_reply = NULL; @@ -367,11 +369,18 @@ void CDownloader::onDownloadFinished() } else { - bool ok = NLMISC::CFile::setFileModificationDate(m_fullPath.toUtf8().constData(), m_lastModified.toTime_t()); + if (QFileInfo(m_fullPath).size() == m_size) + { + bool ok = NLMISC::CFile::setFileModificationDate(m_fullPath.toUtf8().constData(), m_lastModified.toTime_t()); - if (m_listener) m_listener->operationSuccess(m_size); + if (m_listener) m_listener->operationSuccess(m_size); - emit downloadDone(); + emit downloadDone(); + } + else + { + m_listener->operationFail(tr("HTTP error: %1").arg(status)); + } } } @@ -383,10 +392,6 @@ void CDownloader::onError(QNetworkReply::NetworkError error) { m_listener->operationStop(); } - else - { - m_listener->operationFail(tr("Network error: %1").arg(error)); - } } void CDownloader::onDownloadProgress(qint64 current, qint64 total)