diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2007-10-07 21:47:49 +0000 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2007-10-07 21:47:49 +0000 |
commit | 2b2c53689559de30968a5695d6b75ccccbd77570 (patch) | |
tree | 1377df20cd3cf4944eb314a3d35fba0802ef9b86 | |
parent | 22cf8adf01bac924e2581458483a28dfd776c186 (diff) | |
download | rockbox-2b2c53689559de30968a5695d6b75ccccbd77570.tar.gz rockbox-2b2c53689559de30968a5695d6b75ccccbd77570.zip |
Upon uninstallation only remove a file if it isn't used in another section. A possible problematic case would've been two themes installing the same font.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15028 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | rbutil/rbutilqt/uninstall.cpp | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/rbutil/rbutilqt/uninstall.cpp b/rbutil/rbutilqt/uninstall.cpp index 2e96d49081..4bd5c90485 100644 --- a/rbutil/rbutilqt/uninstall.cpp +++ b/rbutil/rbutilqt/uninstall.cpp | |||
@@ -44,36 +44,58 @@ void Uninstaller::uninstall(ProgressloggerInterface* dp) | |||
44 | m_dp->setProgressMax(0); | 44 | m_dp->setProgressMax(0); |
45 | m_dp->addItem(tr("Starting Uninstallation"),LOGINFO); | 45 | m_dp->addItem(tr("Starting Uninstallation"),LOGINFO); |
46 | 46 | ||
47 | QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0); | 47 | QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, this); |
48 | 48 | ||
49 | for(int i=0; i< uninstallSections.size() ; i++) | 49 | for(int i=0; i< uninstallSections.size() ; i++) |
50 | { | 50 | { |
51 | m_dp->addItem(tr("Uninstalling ") + uninstallSections.at(i) + " ...",LOGINFO); | 51 | m_dp->addItem(tr("Uninstalling ") + uninstallSections.at(i) + " ...",LOGINFO); |
52 | // create list of all other install sections | ||
53 | QStringList sections = installlog.childGroups(); | ||
54 | sections.removeAt(sections.indexOf(uninstallSections.at(i))); | ||
52 | installlog.beginGroup(uninstallSections.at(i)); | 55 | installlog.beginGroup(uninstallSections.at(i)); |
53 | QStringList toDeleteList = installlog.allKeys(); | 56 | QStringList toDeleteList = installlog.allKeys(); |
54 | QStringList dirList; | 57 | QStringList dirList; |
58 | installlog.endGroup(); | ||
55 | 59 | ||
56 | // iterate over all entrys | 60 | // iterate over all entries |
57 | for(int j =0; j < toDeleteList.size(); j++ ) | 61 | for(int j =0; j < toDeleteList.size(); j++ ) |
58 | { | 62 | { |
63 | // check if current file is in use by another section | ||
64 | bool deleteFile = true; | ||
65 | for(int s = 0; s < sections.size(); s++) | ||
66 | { | ||
67 | installlog.beginGroup(sections.at(s)); | ||
68 | if(installlog.contains(toDeleteList.at(j))) | ||
69 | { | ||
70 | deleteFile = false; | ||
71 | qDebug() << "file still in use:" << toDeleteList.at(j); | ||
72 | } | ||
73 | installlog.endGroup(); | ||
74 | } | ||
75 | |||
76 | installlog.beginGroup(uninstallSections.at(i)); | ||
59 | QFileInfo toDelete(m_mountpoint + "/" + toDeleteList.at(j)); | 77 | QFileInfo toDelete(m_mountpoint + "/" + toDeleteList.at(j)); |
60 | if(toDelete.isFile()) // if it is a file remove it | 78 | if(toDelete.isFile()) // if it is a file remove it |
61 | { | 79 | { |
62 | if(!QFile::remove(toDelete.filePath())) | 80 | if(deleteFile && !QFile::remove(toDelete.filePath())) |
63 | m_dp->addItem(tr("Could not delete: ")+ toDelete.filePath(),LOGWARNING); | 81 | m_dp->addItem(tr("Could not delete: ")+ toDelete.filePath(),LOGWARNING); |
64 | installlog.remove(toDeleteList.at(j)); | 82 | installlog.remove(toDeleteList.at(j)); |
65 | } | 83 | } |
66 | else // if it is a dir, remember it for later deletion | 84 | else // if it is a dir, remember it for later deletion |
67 | { | 85 | { |
86 | // no need to keep track on folders still in use -- only empty | ||
87 | // folders will be rm'ed. | ||
68 | dirList << toDeleteList.at(j); | 88 | dirList << toDeleteList.at(j); |
69 | } | 89 | } |
90 | installlog.endGroup(); | ||
70 | } | 91 | } |
71 | // delete the dirs | 92 | // delete the dirs |
93 | installlog.beginGroup(uninstallSections.at(i)); | ||
72 | for(int j=0; j < dirList.size(); j++ ) | 94 | for(int j=0; j < dirList.size(); j++ ) |
73 | { | 95 | { |
74 | installlog.remove(dirList.at(j)); | 96 | installlog.remove(dirList.at(j)); |
75 | QDir dir(m_mountpoint); | 97 | QDir dir(m_mountpoint); |
76 | dir.rmdir(dirList.at(j)); | 98 | dir.rmdir(dirList.at(j)); // rm works only on empty folders |
77 | } | 99 | } |
78 | 100 | ||
79 | installlog.endGroup(); | 101 | installlog.endGroup(); |