Mercurial > trustbridge
comparison ui/mainwindow.cpp @ 857:9bab4fc3a1fe
Delete old lists and rename the currently installed list to list-installed.txt
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Mon, 04 Aug 2014 15:06:16 +0200 |
parents | d33834129d2a |
children | 4efd6378c001 |
comparison
equal
deleted
inserted
replaced
856:797aa8d9c785 | 857:9bab4fc3a1fe |
---|---|
27 #include <QLabel> | 27 #include <QLabel> |
28 #include <QImage> | 28 #include <QImage> |
29 #include <QCheckBox> | 29 #include <QCheckBox> |
30 #include <QButtonGroup> | 30 #include <QButtonGroup> |
31 #include <QToolButton> | 31 #include <QToolButton> |
32 #include <QStandardPaths> | |
32 | 33 |
33 #include "certificatelist.h" | 34 #include "certificatelist.h" |
34 #include "downloader.h" | 35 #include "downloader.h" |
35 #include "helpdialog.h" | 36 #include "helpdialog.h" |
36 #include "aboutdialog.h" | 37 #include "aboutdialog.h" |
1066 | 1067 |
1067 if (listFileName.isEmpty() || !listFileDate.isValid()) { | 1068 if (listFileName.isEmpty() || !listFileDate.isValid()) { |
1068 qWarning() << "Error accessing settings"; | 1069 qWarning() << "Error accessing settings"; |
1069 return; /* Try again with next check */ | 1070 return; /* Try again with next check */ |
1070 } | 1071 } |
1071 | 1072 /* Rename the installed list to list-installed.txt so that external |
1072 mSettings.setValue("List/installed", listFileName); | 1073 * programs (like the uninstaller can easily recognize it). */ |
1074 QString dataLoc = | |
1075 QStandardPaths::writableLocation(QStandardPaths::DataLocation); | |
1076 QDir dataDir(dataLoc); | |
1077 if (!dataDir.exists()) { | |
1078 /* Should not happen */ | |
1079 qWarning() << "Data dir removed."; | |
1080 return; | |
1081 } | |
1082 | |
1083 QFileInfo oldList (dataDir.absoluteFilePath("list-installed.txt")); | |
1084 if (oldList.exists()) { | |
1085 qDebug() << "Removing old list: " << oldList.filePath(); | |
1086 if (!QFile::remove(oldList.filePath())) { | |
1087 qWarning() << "Removal of old list failed."; | |
1088 return; | |
1089 } | |
1090 } | |
1091 QFile newList(listFileName); | |
1092 if (!newList.rename(oldList.filePath())) { | |
1093 qWarning() << "Failed to rename new list."; | |
1094 return; | |
1095 } | |
1096 | |
1097 mSettings.setValue("List/installed", oldList.filePath()); | |
1073 mSettings.setValue("List/installedDate", listFileDate); | 1098 mSettings.setValue("List/installedDate", listFileDate); |
1074 mInstalledList = mListToInstall; | 1099 mInstalledList = CertificateList(oldList.filePath().toUtf8().constData()); |
1100 if (!mInstalledList.isValid()) { | |
1101 /* Something went wrong. Go back to square one. */ | |
1102 qWarning () << "List corrupted after installation"; | |
1103 mInstalledList = CertificateList(); | |
1104 QFile::remove(oldList.filePath()); | |
1105 mSettings.remove("List/installed"); | |
1106 mSettings.remove("List/installedDate"); | |
1107 } | |
1075 mListToInstall = CertificateList(); | 1108 mListToInstall = CertificateList(); |
1109 | |
1076 } | 1110 } |
1077 mUpdatesManual->clear(); | 1111 mUpdatesManual->clear(); |
1078 loadCertificateList(); | 1112 loadCertificateList(); |
1079 } | 1113 } |
1080 | 1114 |