fix updater UI repaints

This commit is contained in:
Comma Device
2021-07-29 17:12:12 -07:00
parent 14d26d6d89
commit 56d682831b
3 changed files with 6 additions and 5 deletions
+2 -1
View File
@@ -150,7 +150,8 @@ def flash_partition(target_slot_number: int, partition: dict, cloudlog):
for chunk in unsparsify(downloader):
raw_hash.update(chunk)
out.write(chunk)
print(f"Installing {partition['name']}: {out.tell() / partition_size * 100}", file=sys.stderr)
p = int(out.tell() / partition_size * 100)
print(f"Installing {partition['name']}: {p}")
if raw_hash.hexdigest().lower() != partition['hash_raw'].lower():
raise Exception(f"Unsparse hash mismatch '{raw_hash.hexdigest().lower()}'")
Binary file not shown.
+4 -4
View File
@@ -136,24 +136,24 @@ Updater::Updater(const QString &updater_path, const QString &manifest_path, QWid
void Updater::installUpdate() {
setCurrentWidget(progress);
QObject::connect(&proc, &QProcess::readyReadStandardError, this, &Updater::readProgress);
QObject::connect(&proc, &QProcess::readyReadStandardOutput, this, &Updater::readProgress);
QObject::connect(&proc, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), this, &Updater::updateFinished);
proc.setProcessChannelMode(QProcess::ForwardedOutputChannel);
proc.setProcessChannelMode(QProcess::ForwardedErrorChannel);
proc.start(updater, {"--swap", manifest});
}
void Updater::readProgress() {
auto lines = QString(proc.readAllStandardError());
auto lines = QString(proc.readAllStandardOutput());
for (const QString &line : lines.trimmed().split("\n")) {
auto parts = line.split(":");
if (parts.size() == 2) {
text->setText(parts[0]);
bar->setValue((int)parts[1].toDouble());
repaint();
} else {
qDebug() << line;
}
}
update();
}
void Updater::updateFinished(int exitCode, QProcess::ExitStatus exitStatus) {