From 0cf14984cc5d74a864e8ccbcff12998c7daf37c4 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Fri, 24 Jul 2020 09:49:44 +0200 Subject: [PATCH] client: avoid division by zero in avg speed calculation, be more accurate using micros vs. as_secs_f64 allows to have it calculated as usize bytes, easier to handle - this was also used when it still lived in upload_chunk_info_stream Co-authored-by: Stoiko Ivanov Signed-off-by: Thomas Lamprecht --- src/client/backup_writer.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/backup_writer.rs b/src/client/backup_writer.rs index 7e5adb3c..2344045f 100644 --- a/src/client/backup_writer.rs +++ b/src/client/backup_writer.rs @@ -264,7 +264,7 @@ impl BackupWriter { crate::tools::format::strip_server_file_expenstion(archive_name.clone()) }; if archive_name != CATALOG_NAME { - let speed: HumanByte = (uploaded / (duration.as_secs() as usize)).into(); + let speed: HumanByte = ((uploaded * 1_000_000) / (duration.as_micros() as usize)).into(); let uploaded: HumanByte = uploaded.into(); println!("{}: had to upload {} from {} in {}s, avgerage speed {}/s).", archive, uploaded, vsize_h, duration.as_secs(), speed); } else {