Handle redirects when downloading updates

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>
This commit is contained in:
Kevin Ottens 2020-10-05 15:48:39 +02:00
parent 01152d3f37
commit f39542688a
No known key found for this signature in database
GPG key ID: 074BBBCB8DECC9E2

View 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);