From 580c95ecb77e075dfa91f2e9bb390d5795fae27b Mon Sep 17 00:00:00 2001 From: kh1 Date: Thu, 3 Apr 2014 13:17:59 +0200 Subject: Fix and update how the sha files and packages are downloaded. Fixes a possible messed up download chain once the archive download failed. We need in turn call fetchNextArchiveHash as we will remove both the hash and the package, though this does not reset the last checksum and therefore the next proper archive download will compare to the wrong SHA. Change-Id: Ib4e569de4f5482123da7357a09b7bd087b5d6cbb Reviewed-by: Niels Weber Reviewed-by: Kai Koehne --- src/libs/installer/downloadarchivesjob.cpp | 37 +++++++++++++----------------- 1 file changed, 16 insertions(+), 21 deletions(-) (limited to 'src/libs/installer/downloadarchivesjob.cpp') diff --git a/src/libs/installer/downloadarchivesjob.cpp b/src/libs/installer/downloadarchivesjob.cpp index 7e1196bcf..332c62f2a 100644 --- a/src/libs/installer/downloadarchivesjob.cpp +++ b/src/libs/installer/downloadarchivesjob.cpp @@ -145,14 +145,13 @@ void DownloadArchivesJob::finishedHashDownload() { Q_ASSERT(m_downloader != 0); - const QString tempFile = m_downloader->downloadedFileName(); - QFile sha1HashFile(tempFile); - if (sha1HashFile.open(QFile::ReadOnly)) + QFile sha1HashFile(m_downloader->downloadedFileName()); + if (sha1HashFile.open(QFile::ReadOnly)) { m_currentHash = sha1HashFile.readAll(); - else + fetchNextArchive(); + } else { finishWithError(tr("Downloading hash signature failed.")); - - fetchNextArchive(); + } } /*! @@ -176,7 +175,7 @@ void DownloadArchivesJob::fetchNextArchive() m_downloader = setupDownloader(QString(), m_core->value(QLatin1String("UrlQueryString"))); if (!m_downloader) { m_archivesToDownload.removeFirst(); - QMetaObject::invokeMethod(this, "fetchNextArchive", Qt::QueuedConnection); + QMetaObject::invokeMethod(this, "fetchNextArchiveHash", Qt::QueuedConnection); return; } @@ -232,22 +231,18 @@ void DownloadArchivesJob::registerFile() finishWithError(tr("Could not verify Hash")); return; } + } else { + ++m_archivesDownloaded; + if (m_progressChangedTimerId) { + killTimer(m_progressChangedTimerId); + m_progressChangedTimerId = 0; + emit progressChanged(double(m_archivesDownloaded) / m_archivesToDownloadCount); + } - fetchNextArchiveHash(); - return; - } - - ++m_archivesDownloaded; - if (m_progressChangedTimerId) { - killTimer(m_progressChangedTimerId); - m_progressChangedTimerId = 0; - emit progressChanged(double(m_archivesDownloaded) / m_archivesToDownloadCount); + const QPair pair = m_archivesToDownload.takeFirst(); + QInstallerCreator::BinaryFormatEngineHandler::instance()->registerArchive(pair.first, + m_downloader->downloadedFileName()); } - - const QPair pair = m_archivesToDownload.takeFirst(); - QInstallerCreator::BinaryFormatEngineHandler::instance()->registerArchive(pair.first, - m_downloader->downloadedFileName()); - fetchNextArchiveHash(); } -- cgit v1.2.3