diff ui/mainwindow.cpp @ 1056:c7db2cc97bad

(issue44) Remove downloaded binaries after update
author Andre Heinecke <andre.heinecke@intevation.de>
date Tue, 09 Sep 2014 17:04:10 +0200
parents 9812983e7650
children db831a204a6b
line wrap: on
line diff
--- a/ui/mainwindow.cpp	Tue Sep 09 17:03:46 2014 +0200
+++ b/ui/mainwindow.cpp	Tue Sep 09 17:04:10 2014 +0200
@@ -379,6 +379,28 @@
     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;
+        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);
 

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