Handle redirects when downloading updates
authorKevin Ottens <kevin.ottens@nextcloud.com>
Mon, 5 Oct 2020 13:48:39 +0000 (15:48 +0200)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Mon, 5 Oct 2020 13:48:39 +0000 (15:48 +0200)
This is necessary for downloads coming from Github for instance. They
are systematically redirected and we'd just fail the download.

Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
src/gui/updater/ocupdater.cpp

index 66528f8dcd0466632f2772b1034bfe345f3e739d..3f772ef01fab193c8fac5bd477b06cc69ef266d3 100644 (file)
@@ -304,7 +304,9 @@ void NSISUpdater::versionInfoArrived(const UpdateInfo &info)
             if (QFile(_targetFile).exists()) {
                 setDownloadState(DownloadComplete);
             } else {
-                QNetworkReply *reply = qnam()->get(QNetworkRequest(QUrl(url)));
+                auto request = QNetworkRequest(QUrl(url));
+                request.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
+                QNetworkReply *reply = qnam()->get(request);
                 connect(reply, &QIODevice::readyRead, this, &NSISUpdater::slotWriteFile);
                 connect(reply, &QNetworkReply::finished, this, &NSISUpdater::slotDownloadFinished);
                 setDownloadState(Downloading);