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
This commit is contained in:
Dominik Riebeling 2022-04-14 23:06:40 +02:00
parent 97176d444e
commit b9c3ab2e04
2 changed files with 13 additions and 5 deletions

View file

@ -57,6 +57,7 @@ void Uninstaller::uninstall(void)
installlog.endGroup();
// iterate over all entries
QStringList deletedItems;
for(int j = 0; j < toDeleteList.size(); j++ )
{
emit logProgress(j, toDeleteList.size());
@ -73,14 +74,13 @@ void Uninstaller::uninstall(void)
installlog.endGroup();
}
installlog.beginGroup(uninstallSections.at(i));
QFileInfo toDelete(m_mountpoint + "/" + toDeleteList.at(j));
if(toDelete.isFile()) // if it is a file remove it
{
if(deleteFile && !QFile::remove(toDelete.filePath()))
emit logItem(tr("Could not delete %1")
.arg(toDelete.filePath()), LOGWARNING);
installlog.remove(toDeleteList.at(j));
deletedItems.append(toDeleteList.at(j));
LOG_INFO() << "deleted:" << toDelete.filePath();
}
else // if it is a dir, remember it for later deletion
@ -89,17 +89,24 @@ void Uninstaller::uninstall(void)
// folders will be rm'ed.
dirList << toDeleteList.at(j);
}
installlog.endGroup();
QCoreApplication::processEvents();
}
// delete the dirs
installlog.beginGroup(uninstallSections.at(i));
for(int j=0; j < dirList.size(); j++ )
for(int j = 0; j < dirList.size(); j++ )
{
installlog.remove(dirList.at(j));
emit logProgress(j, dirList.size());
deletedItems.append(dirList.at(j));
QDir dir(m_mountpoint);
dir.rmdir(dirList.at(j)); // rm works only on empty folders
}
// for speed reasons update log file only at the end.
installlog.beginGroup(uninstallSections.at(i));
for (auto file : deletedItems)
{
installlog.remove(file);
}
installlog.endGroup();
installlog.endGroup();
//installlog.removeGroup(uninstallSections.at(i))

View file

@ -147,6 +147,7 @@ bool ZipUtil::extractArchive(const QString& dest, QString file)
outputFile.close();
emit logProgress(current, entries);
QCoreApplication::processEvents();
}
delete currentFile;
emit logProgress(1, 1);