changeset 1379:831d28c2291d

(issue179) Handle software update even if new version can't be found on server
author Andre Heinecke <andre.heinecke@intevation.de>
date Thu, 15 Jan 2015 12:42:49 +0100
parents 3c61ab983f9b
children 77c9e35657ab
files ui/mainwindow.cpp
diffstat 1 files changed, 16 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/ui/mainwindow.cpp	Thu Jan 15 11:50:19 2015 +0100
+++ b/ui/mainwindow.cpp	Thu Jan 15 12:42:49 2015 +0100
@@ -664,26 +664,25 @@
 {
     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.";
+    qDebug() << "Set last modified date: " << date << " available: " << swAvailableLastMod;
+    if (swAvailableLastMod.isValid() && (!date.isValid() || 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 {
-                if (QFile::remove(fileName)) {
-                    qDebug() << "Removed: " << fileName;
-                } else {
-                    qDebug() << "Failed to remove: " << fileName;
-                }
+                qDebug() << "Failed to remove: " << fileName;
             }
-            /* Clear out available data. */
-            mSettings.remove("Software/available");
-            mSettings.remove("Software/availableDate");
         }
+        /* Clear out available data. */
+        mSettings.remove("Software/available");
+        mSettings.remove("Software/availableDate");
     }
 
     mSettings.beginGroup("Software");

http://wald.intevation.org/projects/trustbridge/