Mercurial > trustbridge
changeset 1259:f1e461340ede
(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.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Fri, 26 Sep 2014 13:18:46 +0200 |
parents | 469c1a04b678 |
children | 82792b3a16bd |
files | ui/mainwindow.cpp |
diffstat | 1 files changed, 24 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- 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