diff --git a/src/bin/proxmox-backup-client.rs b/src/bin/proxmox-backup-client.rs index ffe5b3dd..4bb05bd1 100644 --- a/src/bin/proxmox-backup-client.rs +++ b/src/bin/proxmox-backup-client.rs @@ -510,7 +510,7 @@ async fn list_snapshots(param: Value) -> Result { .sortby("backup-id", false) .sortby("backup-time", false) .column(ColumnConfig::new("backup-id").renderer(render_snapshot_path).header("snapshot")) - .column(ColumnConfig::new("size")) + .column(ColumnConfig::new("size").renderer(tools::format::render_bytes_human_readable)) .column(ColumnConfig::new("files").renderer(render_files)) ; diff --git a/src/tools/format.rs b/src/tools/format.rs index c3aa791b..8fe6aa82 100644 --- a/src/tools/format.rs +++ b/src/tools/format.rs @@ -50,6 +50,19 @@ pub fn render_bool_with_default_true(value: &Value, _record: &Value) -> Result Result { + if value.is_null() { return Ok(String::new()); } + let text = match value.as_u64() { + Some(bytes) => { + HumanByte::from(bytes).to_string() + } + None => { + value.to_string() + } + }; + Ok(text) +} + pub struct HumanByte { b: usize, }