From a1abbd9e05c80584d831b1d12c27c5f7d731cece Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sat, 28 May 2016 19:54:17 +0200 Subject: NOISSUE refactor *Download into more, smaller pieces * Download is now Download. * Download uses Sink subclasses to process various events. * Validators can be used to further customize the Sink behaviour. --- api/logic/updater/DownloadTask.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'api/logic/updater/DownloadTask.cpp') diff --git a/api/logic/updater/DownloadTask.cpp b/api/logic/updater/DownloadTask.cpp index 6947e8bf..9bb31695 100644 --- a/api/logic/updater/DownloadTask.cpp +++ b/api/logic/updater/DownloadTask.cpp @@ -43,22 +43,19 @@ void DownloadTask::loadVersionInfo() { setStatus(tr("Loading version information...")); - m_currentVersionFileListDownload.reset(); - m_newVersionFileListDownload.reset(); - NetJob *netJob = new NetJob("Version Info"); // Find the index URL. QUrl newIndexUrl = QUrl(m_status.newRepoUrl).resolved(QString::number(m_status.newVersionId) + ".json"); qDebug() << m_status.newRepoUrl << " turns into " << newIndexUrl; - netJob->addNetAction(m_newVersionFileListDownload = ByteArrayDownload::make(newIndexUrl)); + netJob->addNetAction(m_newVersionFileListDownload = Net::Download::makeByteArray(newIndexUrl, &newVersionFileListData)); // If we have a current version URL, get that one too. if (!m_status.currentRepoUrl.isEmpty()) { QUrl cIndexUrl = QUrl(m_status.currentRepoUrl).resolved(QString::number(m_status.currentVersionId) + ".json"); - netJob->addNetAction(m_currentVersionFileListDownload = ByteArrayDownload::make(cIndexUrl)); + netJob->addNetAction(m_currentVersionFileListDownload = Net::Download::makeByteArray(cIndexUrl, ¤tVersionFileListData)); qDebug() << m_status.currentRepoUrl << " turns into " << cIndexUrl; } @@ -92,7 +89,7 @@ void DownloadTask::processDownloadedVersionInfo() setStatus(tr("Reading file list for new version...")); qDebug() << "Reading file list for new version..."; QString error; - if (!parseVersionInfo(m_newVersionFileListDownload->m_data, m_newVersionFileList, error)) + if (!parseVersionInfo(newVersionFileListData, m_newVersionFileList, error)) { qCritical() << error; emitFailed(error); @@ -106,7 +103,7 @@ void DownloadTask::processDownloadedVersionInfo() qDebug() << "Reading file list for current version..."; // if this fails, it's not a complete loss. QString error; - if(!parseVersionInfo( m_currentVersionFileListDownload->m_data, m_currentVersionFileList, error)) + if(!parseVersionInfo( currentVersionFileListData, m_currentVersionFileList, error)) { qDebug() << error << "This is not a fatal error."; } -- cgit v1.2.3