From 146bd44b09d98be5df7bcb5a878ea55a94bf3b65 Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Tue, 27 Sep 2022 18:55:29 +0200 Subject: [PATCH] use correct version copmparison on NSIS updater: fix update from rc Signed-off-by: Matthieu Gallien --- src/gui/updater/ocupdater.cpp | 44 ++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/src/gui/updater/ocupdater.cpp b/src/gui/updater/ocupdater.cpp index 4c036321f..7454f62a1 100644 --- a/src/gui/updater/ocupdater.cpp +++ b/src/gui/updater/ocupdater.cpp @@ -259,6 +259,7 @@ bool OCUpdater::updateSucceeded() const void OCUpdater::slotVersionInfoArrived() { + qCInfo(lcUpdater()) << "received a reply"; _timeoutWatchdog->stop(); auto *reply = qobject_cast(sender()); reply->deleteLater(); @@ -358,28 +359,32 @@ void NSISUpdater::versionInfoArrived(const UpdateInfo &info) { qCInfo(lcUpdater) << "No version information available at the moment"; setDownloadState(UpToDate); - } else if (infoVersion <= currVersion - || infoVersion <= seenVersion) { - qCInfo(lcUpdater) << "Client is on latest version!"; - setDownloadState(UpToDate); } else { - QString url = info.downloadUrl(); - if (url.isEmpty()) { - showNoUrlDialog(info); + qint64 currentVer = Helper::currentVersionToInt(); + qint64 remoteVer = Helper::stringVersionToInt(info.version()); + + if (info.version().isEmpty() || currentVer >= remoteVer) { + qCInfo(lcUpdater) << "Client is on latest version!"; + setDownloadState(UpToDate); } else { - _targetFile = cfg.configPath() + url.mid(url.lastIndexOf('/')+1); - if (QFile(_targetFile).exists()) { - setDownloadState(DownloadComplete); + QString url = info.downloadUrl(); + if (url.isEmpty()) { + showNoUrlDialog(info); } else { - 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); - _file.reset(new QTemporaryFile); - _file->setAutoRemove(true); - _file->open(); + _targetFile = cfg.configPath() + url.mid(url.lastIndexOf('/')+1); + if (QFile(_targetFile).exists()) { + setDownloadState(DownloadComplete); + } else { + 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); + _file.reset(new QTemporaryFile); + _file->setAutoRemove(true); + _file->open(); + } } } } @@ -554,6 +559,7 @@ void PassiveUpdateNotifier::versionInfoArrived(const UpdateInfo &info) qCInfo(lcUpdater) << "Client is on latest version!"; setDownloadState(UpToDate); } else { + qCInfo(lcUpdater) << "Client is on older version. We will update!"; setDownloadState(UpdateOnlyAvailableThroughSystem); } }