diff --git a/src/platform/qt/ForwarderController.cpp b/src/platform/qt/ForwarderController.cpp index fe0530a73..56e202019 100644 --- a/src/platform/qt/ForwarderController.cpp +++ b/src/platform/qt/ForwarderController.cpp @@ -180,6 +180,9 @@ void ForwarderController::downloadBuild(const QUrl& url) { connectReply(reply, BASE, &ForwarderController::gotBuild); connect(reply, &QNetworkReply::readyRead, this, [this, reply]() { + if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() / 100 != 2) { + return; + } QByteArray data = reply->readAll(); m_sourceFile.write(data); }); @@ -236,8 +239,13 @@ void ForwarderController::connectReply(QNetworkReply* reply, Download download, emit buildFailed(); }); - connect(reply, &QNetworkReply::finished, this, [this, reply, next]() { - (this->*next)(reply); + connect(reply, &QNetworkReply::finished, this, [this, reply, download, next]() { + if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() / 100 == 3) { + QNetworkReply* newReply = GBAApp::app()->httpGet(reply->header(QNetworkRequest::LocationHeader).toString()); + connectReply(newReply, download, next); + } else { + (this->*next)(reply); + } }); connect(reply, &QNetworkReply::downloadProgress, this, [this, download](qint64 bytesReceived, qint64 bytesTotal) { emit downloadProgress(download, bytesReceived, bytesTotal); diff --git a/src/platform/qt/GBAApp.cpp b/src/platform/qt/GBAApp.cpp index 1e3c6a894..30287262a 100644 --- a/src/platform/qt/GBAApp.cpp +++ b/src/platform/qt/GBAApp.cpp @@ -82,7 +82,9 @@ GBAApp::GBAApp(int& argc, char* argv[], ConfigController* config) m_configController->updateOption("useDiscordPresence"); #endif +#if (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)) m_netman.setRedirectPolicy(QNetworkRequest::NoLessSafeRedirectPolicy); +#endif cleanupAfterUpdate();