From 794102b32cb9b9c0ddb0c8268c572acb256dd6ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 30 Apr 2017 02:54:37 +0200 Subject: NOISSUE less jumpy download progress bars and redirect URL fix --- api/logic/net/Download.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'api/logic/net/Download.cpp') diff --git a/api/logic/net/Download.cpp b/api/logic/net/Download.cpp index b346d5e0..97b03ac2 100644 --- a/api/logic/net/Download.cpp +++ b/api/logic/net/Download.cpp @@ -106,6 +106,17 @@ void Download::executeTask() void Download::downloadProgress(qint64 bytesReceived, qint64 bytesTotal) { + // FIXME: ignore unknown size. for now. + if(bytesTotal == -1) + { + return; + } + // FIXME: ignore redirects... for now. + auto redirectURL = getRedirect(); + if(!redirectURL.isEmpty()) + { + return; + } m_progressTotal = bytesTotal; m_progress = bytesReceived; emit progress(bytesReceived, bytesTotal); @@ -134,7 +145,7 @@ void Download::downloadError(QNetworkReply::NetworkError error) } } -bool Download::handleRedirect() +QString Download::getRedirect() { QVariant redirect = m_reply->header(QNetworkRequest::LocationHeader); QString redirectURL; @@ -151,10 +162,15 @@ bool Download::handleRedirect() redirectURL = m_reply->url().scheme() + ":" + data; } } + return redirectURL; +} + +bool Download::handleRedirect() +{ + auto redirectURL = getRedirect(); if (!redirectURL.isEmpty()) { - m_url = QUrl(redirect.toString()); - qDebug() << "Following redirect to " << m_url.toString(); + m_url = QUrl(redirectURL); start(); return true; } -- cgit v1.2.3