[pve-devel] [PATCH installer 6/6] auto: avoid printing unnecessary progress update lines
Christoph Heiss
c.heiss at proxmox.com
Thu May 16 15:39:36 CEST 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>
---
proxmox-auto-installer/src/bin/proxmox-auto-installer.rs | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/proxmox-auto-installer/src/bin/proxmox-auto-installer.rs b/proxmox-auto-installer/src/bin/proxmox-auto-installer.rs
index 96a48bd..a72181f 100644
--- a/proxmox-auto-installer/src/bin/proxmox-auto-installer.rs
+++ b/proxmox-auto-installer/src/bin/proxmox-auto-installer.rs
@@ -140,6 +140,8 @@ 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.;
+
for line in reader.lines() {
let line = match line {
Ok(line) => line,
@@ -174,8 +176,10 @@ fn run_installation(
let percentage = ratio * 100.;
if let Some(text) = text {
info!("progress {percentage:>5.1} % - {text}");
- } else {
+ last_progress_percentage = percentage;
+ } else if (percentage - last_progress_percentage) > 0.1 {
info!("progress {percentage:>5.1} %");
+ last_progress_percentage = percentage;
}
}
LowLevelMessage::Finished { state, message } => {
--
2.44.0
More information about the pve-devel
mailing list