[pve-devel] [PATCH installer v2 5/6] auto: avoid printing unnecessary progress update lines
Christoph Heiss
c.heiss at proxmox.com
Mon Nov 25 12:27:19 CET 2024
In case the progress message did not contain any text and the percentage
did not change, don't print another (useless) line.
Signed-off-by: Christoph Heiss <c.heiss at proxmox.com>
---
Changes v1 -> v2:
* if the percentage was updated w/o any text, reuse the last message
.../src/bin/proxmox-auto-installer.rs | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/proxmox-auto-installer/src/bin/proxmox-auto-installer.rs b/proxmox-auto-installer/src/bin/proxmox-auto-installer.rs
index 9d1dff4..ece9a94 100644
--- a/proxmox-auto-installer/src/bin/proxmox-auto-installer.rs
+++ b/proxmox-auto-installer/src/bin/proxmox-auto-installer.rs
@@ -173,6 +173,9 @@ fn run_installation(
let mut lowlevel_log = File::create("/tmp/install-low-level.log")
.map_err(|err| format_err!("failed to open low-level installer logfile: {err}"))?;
+ let mut last_progress_percentage = 0.;
+ let mut last_progress_text = None;
+
for line in reader.lines() {
let line = match line {
Ok(line) => line,
@@ -207,8 +210,16 @@ fn run_installation(
let percentage = ratio * 100.;
if let Some(text) = text {
info!("progress {percentage:>5.1} % - {text}");
- } else {
- info!("progress {percentage:>5.1} %");
+ last_progress_percentage = percentage;
+ last_progress_text = Some(text);
+ } else if (percentage - last_progress_percentage) > 0.1 {
+ if let Some(text) = &last_progress_text {
+ info!("progress {percentage:>5.1} % - {text}");
+ } else {
+ info!("progress {percentage:>5.1} %");
+ }
+
+ last_progress_percentage = percentage;
}
}
LowLevelMessage::Finished { state, message } => {
--
2.47.0
More information about the pve-devel
mailing list