perf(progress): report real progress instead of a bouncing bar

pacman restarts its "(1/24)" counter at every phase of a transaction, so the
bar was fed 0 percent, 100 percent, 0 percent again a few times per update —
and Flatpak/AUR buffered their whole output, which left it indeterminate for
the entire run. A shared ProgressTracker now folds every counter, file
percentage and package step into one value that only moves forward, the
providers stream their output as it is produced, and each provider owns a
slice of the bar so a multi-provider update keeps advancing. pacman -Qu is
cached like the other read queries, so the sidebar badge, the updates screen
and the update button share a single process.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
BlackAngelTV committed 2026-09-16 22:40:39 +02:00
1 parent ed58e87520
commit b26e907221
12 files changed
+590 -138

No files matched your search

+12 -4
View File
@@ -98,19 +98,27 @@ void InstallWorker::run() {
return;
}
const int providerCount = static_cast<int>(m_providers.size());
bool success = true;
for (IPackageManager* pm : m_providers) {
for (int index = 0; index < providerCount; ++index) {
IPackageManager* pm = m_providers[static_cast<size_t>(index)];
// Prefix progress lines with the provider when several run at once.
// A real percentage (>= 0) also drives the determinate status bar bar.
auto cb = [this, pm](const std::string& msg, int percent) {
if (m_providers.size() > 1) {
auto cb = [this, pm, index, providerCount](const std::string& msg, int percent) {
if (providerCount > 1) {
emit progress(QString("[%1] %2")
.arg(QString::fromStdString(pm->getName()),
QString::fromStdString(msg)));
} else {
emit progress(QString::fromStdString(msg));
}
if (percent >= 0) emit progressValue(percent);
if (percent < 0) return;
// Providers run one after the other, so each one owns an equal
// slice of the bar. Without this the bar dropped back to 0 when the
// second provider (flatpak, after pacman) started its own count.
const int scaled = (index * 100 + percent) / providerCount;
emit progressValue(std::min(scaled, 99));
};
// Keep running the remaining providers even if one fails.