[PATCH 4 of 6] (issue44) Move check if the SW was updated into setLastModifiedSWDate

Wald Commits scm-commit at wald.intevation.org
Fri Sep 26 15:26:23 CEST 2014


# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1411730326 -7200
# Node ID f1e461340ede7d7620511a370d4fa1c29a13983b
# Parent  469c1a04b678b20dd5e36bc71b48b26b12cf9917
(issue44) Move check if the SW was updated into setLastModifiedSWDate

    setLastModifiedSWDate is ideally only called once to register
    a new version so this is the best place to note if an update
    has been installed.

diff -r 469c1a04b678 -r f1e461340ede ui/mainwindow.cpp
--- a/ui/mainwindow.cpp	Fri Sep 26 12:45:27 2014 +0200
+++ b/ui/mainwindow.cpp	Fri Sep 26 13:18:46 2014 +0200
@@ -511,31 +511,6 @@
     }
     QDateTime listInstalledLastMod = mSettings.value("List/installedDate").toDateTime();
     QDateTime swInstalledLastMod = mSettings.value("Software/installedDate").toDateTime();
-
-    QDateTime swAvailableLastMod = mSettings.value("Software/availableDate").toDateTime();
-
-    if (swAvailableLastMod.isValid()) {
-        qDebug() << "Installed an update: " << swInstalledLastMod <<
-            " available " << swAvailableLastMod;
-        syslog_info_printf ("Software has been updated to version: %s\n",
-                QApplication::applicationVersion().toUtf8().constData());
-        if (swInstalledLastMod == swAvailableLastMod) {
-            QString fileName = mSettings.value("Software/available").toString();
-            if (fileName.isEmpty()) {
-                qDebug() << "Software marked as available but no filename set.";
-            } else {
-                if (QFile::remove(fileName)) {
-                    qDebug() << "Removed: " << fileName;
-                } else {
-                    qDebug() << "Failed to remove: " << fileName;
-                }
-            }
-            /* Clear out available data. */
-            mSettings.remove("Software/available");
-            mSettings.remove("Software/availableDate");
-        }
-    }
-
     QString listResource = QString::fromLatin1(LIST_RESOURCE);
     QString swResource = QString::fromLatin1(SW_RESOURCE);
 
@@ -608,6 +583,30 @@
 
 void MainWindow::setLastModifiedSWDate(const QDateTime &date)
 {
+    QDateTime swAvailableLastMod = mSettings.value("Software/availableDate").toDateTime();
+
+    if (swAvailableLastMod.isValid() && date.isValid()) {
+        if (date >= swAvailableLastMod) {
+            qDebug() << "Installed an update: " << date <<
+                " available was " << swAvailableLastMod;
+            syslog_info_printf ("Software has been updated to version: %s\n",
+                QApplication::applicationVersion().toUtf8().constData());
+            QString fileName = mSettings.value("Software/available").toString();
+            if (fileName.isEmpty()) {
+                qDebug() << "Software marked as available but no filename set.";
+            } else {
+                if (QFile::remove(fileName)) {
+                    qDebug() << "Removed: " << fileName;
+                } else {
+                    qDebug() << "Failed to remove: " << fileName;
+                }
+            }
+            /* Clear out available data. */
+            mSettings.remove("Software/available");
+            mSettings.remove("Software/availableDate");
+        }
+    }
+
     mSettings.beginGroup("Software");
 #ifdef IS_TAG_BUILD
     /* We accept an invalid date to force installing any avialable update


More information about the Trustbridge-commits mailing list