diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2022-04-14 23:06:40 +0200 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2022-04-14 23:06:40 +0200 |
commit | b9c3ab2e049124894716305c9aa8a1d7a610d134 (patch) | |
tree | fc8ed899ebb17efbe40d36f75b384a7e34fcc3c0 | |
parent | 97176d444eb377aa4efe83430d87eae0afb793d7 (diff) | |
download | rockbox-b9c3ab2e049124894716305c9aa8a1d7a610d134.tar.gz rockbox-b9c3ab2e049124894716305c9aa8a1d7a610d134.zip |
rbutil: Improve progress & responsiveness on (un)install.
- When uninstalling update the log file only at the end of removing all
files. This gives a major speed improveness since othewise the log
file is written after each file. This slows down things notably,
especially on slow disks.
- Explicitly update the UI during install zip extraction. Avoids
progress seemingly hanging due to the UI not getting updated often
enough.
Change-Id: Ib353a92e02a7038d6e55f5f88dcfb5085602c0f2
-rw-r--r-- | utils/rbutilqt/base/uninstall.cpp | 17 | ||||
-rw-r--r-- | utils/rbutilqt/base/ziputil.cpp | 1 |
2 files changed, 13 insertions, 5 deletions
diff --git a/utils/rbutilqt/base/uninstall.cpp b/utils/rbutilqt/base/uninstall.cpp index 6b4e08b55a..e6ced811d6 100644 --- a/utils/rbutilqt/base/uninstall.cpp +++ b/utils/rbutilqt/base/uninstall.cpp | |||
@@ -57,6 +57,7 @@ void Uninstaller::uninstall(void) | |||
57 | installlog.endGroup(); | 57 | installlog.endGroup(); |
58 | 58 | ||
59 | // iterate over all entries | 59 | // iterate over all entries |
60 | QStringList deletedItems; | ||
60 | for(int j = 0; j < toDeleteList.size(); j++ ) | 61 | for(int j = 0; j < toDeleteList.size(); j++ ) |
61 | { | 62 | { |
62 | emit logProgress(j, toDeleteList.size()); | 63 | emit logProgress(j, toDeleteList.size()); |
@@ -73,14 +74,13 @@ void Uninstaller::uninstall(void) | |||
73 | installlog.endGroup(); | 74 | installlog.endGroup(); |
74 | } | 75 | } |
75 | 76 | ||
76 | installlog.beginGroup(uninstallSections.at(i)); | ||
77 | QFileInfo toDelete(m_mountpoint + "/" + toDeleteList.at(j)); | 77 | QFileInfo toDelete(m_mountpoint + "/" + toDeleteList.at(j)); |
78 | if(toDelete.isFile()) // if it is a file remove it | 78 | if(toDelete.isFile()) // if it is a file remove it |
79 | { | 79 | { |
80 | if(deleteFile && !QFile::remove(toDelete.filePath())) | 80 | if(deleteFile && !QFile::remove(toDelete.filePath())) |
81 | emit logItem(tr("Could not delete %1") | 81 | emit logItem(tr("Could not delete %1") |
82 | .arg(toDelete.filePath()), LOGWARNING); | 82 | .arg(toDelete.filePath()), LOGWARNING); |
83 | installlog.remove(toDeleteList.at(j)); | 83 | deletedItems.append(toDeleteList.at(j)); |
84 | LOG_INFO() << "deleted:" << toDelete.filePath(); | 84 | LOG_INFO() << "deleted:" << toDelete.filePath(); |
85 | } | 85 | } |
86 | else // if it is a dir, remember it for later deletion | 86 | else // if it is a dir, remember it for later deletion |
@@ -89,17 +89,24 @@ void Uninstaller::uninstall(void) | |||
89 | // folders will be rm'ed. | 89 | // folders will be rm'ed. |
90 | dirList << toDeleteList.at(j); | 90 | dirList << toDeleteList.at(j); |
91 | } | 91 | } |
92 | installlog.endGroup(); | ||
93 | QCoreApplication::processEvents(); | 92 | QCoreApplication::processEvents(); |
94 | } | 93 | } |
95 | // delete the dirs | 94 | // delete the dirs |
96 | installlog.beginGroup(uninstallSections.at(i)); | 95 | installlog.beginGroup(uninstallSections.at(i)); |
97 | for(int j=0; j < dirList.size(); j++ ) | 96 | for(int j = 0; j < dirList.size(); j++ ) |
98 | { | 97 | { |
99 | installlog.remove(dirList.at(j)); | 98 | emit logProgress(j, dirList.size()); |
99 | deletedItems.append(dirList.at(j)); | ||
100 | QDir dir(m_mountpoint); | 100 | QDir dir(m_mountpoint); |
101 | dir.rmdir(dirList.at(j)); // rm works only on empty folders | 101 | dir.rmdir(dirList.at(j)); // rm works only on empty folders |
102 | } | 102 | } |
103 | // for speed reasons update log file only at the end. | ||
104 | installlog.beginGroup(uninstallSections.at(i)); | ||
105 | for (auto file : deletedItems) | ||
106 | { | ||
107 | installlog.remove(file); | ||
108 | } | ||
109 | installlog.endGroup(); | ||
103 | 110 | ||
104 | installlog.endGroup(); | 111 | installlog.endGroup(); |
105 | //installlog.removeGroup(uninstallSections.at(i)) | 112 | //installlog.removeGroup(uninstallSections.at(i)) |
diff --git a/utils/rbutilqt/base/ziputil.cpp b/utils/rbutilqt/base/ziputil.cpp index 3527e8e881..e285446711 100644 --- a/utils/rbutilqt/base/ziputil.cpp +++ b/utils/rbutilqt/base/ziputil.cpp | |||
@@ -147,6 +147,7 @@ bool ZipUtil::extractArchive(const QString& dest, QString file) | |||
147 | outputFile.close(); | 147 | outputFile.close(); |
148 | 148 | ||
149 | emit logProgress(current, entries); | 149 | emit logProgress(current, entries); |
150 | QCoreApplication::processEvents(); | ||
150 | } | 151 | } |
151 | delete currentFile; | 152 | delete currentFile; |
152 | emit logProgress(1, 1); | 153 | emit logProgress(1, 1); |