Updater: Preserve target version string
authorChristian Kamm <mail@ckamm.de>
Mon, 29 Jul 2019 11:47:38 +0000 (13:47 +0200)
committerCamila (Rebase PR Action) <hello@camila.codes>
Tue, 24 Nov 2020 18:22:33 +0000 (18:22 +0000)
For #7217

src/gui/updater/ocupdater.cpp
src/gui/updater/ocupdater.h

index 996c8c9b9956e3f6d7178d145f74478550cf78a1..c48202b1d9c2d3d4d624c88665316828034d0de2 100644 (file)
@@ -31,6 +31,7 @@ namespace OCC {
 
 static const char updateAvailableC[] = "Updater/updateAvailable";
 static const char updateTargetVersionC[] = "Updater/updateTargetVersion";
+static const char updateTargetVersionStringC[] = "Updater/updateTargetVersionString";
 static const char seenVersionC[] = "Updater/seenVersion";
 static const char autoUpdateAttemptedC[] = "Updater/autoUpdateAttempted";
 
@@ -294,6 +295,7 @@ void NSISUpdater::wipeUpdateData()
         QFile::remove(updateFileName);
     settings.remove(updateAvailableC);
     settings.remove(updateTargetVersionC);
+    settings.remove(updateTargetVersionStringC);
     settings.remove(autoUpdateAttemptedC);
 }
 
@@ -322,6 +324,7 @@ void NSISUpdater::slotDownloadFinished()
     setDownloadState(DownloadComplete);
     qCInfo(lcUpdater) << "Downloaded" << url.toString() << "to" << _targetFile;
     settings.setValue(updateTargetVersionC, updateInfo().version());
+    settings.setValue(updateTargetVersionStringC, updateInfo().versionString());
     settings.setValue(updateAvailableC, _targetFile);
 }
 
@@ -411,7 +414,7 @@ void NSISUpdater::showNoUrlDialog(const UpdateInfo &info)
     msgBox->open();
 }
 
-void NSISUpdater::showUpdateErrorDialog()
+void NSISUpdater::showUpdateErrorDialog(const QString &targetVersion)
 {
     QDialog *msgBox = new QDialog;
     msgBox->setAttribute(Qt::WA_DeleteOnClose);
@@ -435,7 +438,7 @@ void NSISUpdater::showUpdateErrorDialog()
     QString txt = tr("<p>A new version of the %1 Client is available but the updating process failed.</p>"
                      "<p><b>%2</b> has been downloaded. The installed version is %3.</p>")
                       .arg(Utility::escape(Theme::instance()->appNameGUI()),
-                          Utility::escape(updateInfo().versionString()), Utility::escape(clientVersion()));
+                          Utility::escape(targetVersion), Utility::escape(clientVersion()));
 
     lbl->setText(txt);
     lbl->setTextFormat(Qt::RichText);
@@ -488,7 +491,7 @@ bool NSISUpdater::handleStartup()
                 return false;
             } else {
                 // auto update failed. Ask user what to do
-                showUpdateErrorDialog();
+                showUpdateErrorDialog(settings.value(updateTargetVersionStringC).toString());
                 return false;
             }
         } else {
index 6de88b70440d24ffcf655e58ecc36c5baa6f5f76..dbdb6be51774e72a33f51fdd51d44ed324348fa0 100644 (file)
@@ -158,7 +158,7 @@ private slots:
 private:
     void wipeUpdateData();
     void showNoUrlDialog(const UpdateInfo &info);
-    void showUpdateErrorDialog();
+    void showUpdateErrorDialog(const QString &targetVersion);
     void versionInfoArrived(const UpdateInfo &info) override;
     QScopedPointer<QTemporaryFile> _file;
     QString _targetFile;