summaryrefslogtreecommitdiffstats
path: root/api/logic/net/Download.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'api/logic/net/Download.cpp')
-rw-r--r--api/logic/net/Download.cpp22
1 files changed, 19 insertions, 3 deletions
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;
}