[PATCH 2 of 2] (issue44) Remove downloaded binaries after update

Wald Commits scm-commit at wald.intevation.org
Tue Sep 9 17:04:15 CEST 2014


# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1410275050 -7200
# Node ID c7db2cc97bade73d1d4aac5a22535162524e3ba4
# Parent  9812983e76504168f858264bac87446b1c6f209f
(issue44) Remove downloaded binaries after update

diff -r 9812983e7650 -r c7db2cc97bad ui/mainwindow.cpp
--- 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);
 


More information about the Trustbridge-commits mailing list