]> git.proxmox.com Git - proxmox-backup.git/blobdiff - proxmox-backup-client/src/main.rs
fix #4638: proxmox-backup-client: status: guard against div by zero
[proxmox-backup.git] / proxmox-backup-client / src / main.rs
index 5519810861ce4f88df233f254621ecf56af4314e..5a804d95ecd43c771eec29da3446e74d3ef6b270 100644 (file)
@@ -1590,9 +1590,12 @@ async fn status(param: Value) -> Result<Value, Error> {
         let v = v.as_u64().unwrap();
         let total = record["total"].as_u64().unwrap();
         let roundup = total / 200;
-        let per = ((v + roundup) * 100) / total;
-        let info = format!(" ({} %)", per);
-        Ok(format!("{} {:>8}", v, info))
+        if let Some(per) = ((v + roundup) * 100).checked_div(total) {
+            let info = format!(" ({} %)", per);
+            Ok(format!("{} {:>8}", v, info))
+        } else {
+            bail!("Cannot render total percentage: denominator is zero");
+        }
     };
 
     let options = default_table_format_options()