chore: update bytesize dependency to 2.3

include code update to follow display management change.
This commit is contained in:
Gwen Lg
2026-01-29 00:09:54 +01:00
committed by Alex
parent 934c4c31f1
commit 566a0b44c0
6 changed files with 25 additions and 27 deletions
Generated
+2 -2
View File
@@ -673,9 +673,9 @@ dependencies = [
[[package]]
name = "bytesize"
version = "1.3.3"
version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e93abca9e28e0a1b9877922aacb20576e05d4679ffa78c3d6dc22a26a216659"
checksum = "6bd91ee7b2422bcb158d90ef4d14f75ef67f340943fc4149891dcce8f8b972a3"
[[package]]
name = "byteview"
+1 -1
View File
@@ -46,7 +46,7 @@ backtrace = "0.3"
base64 = "0.21"
blake2 = "0.10"
bytes = "1.0"
bytesize = "1.1"
bytesize = "2.3"
cfg-if = "1.0"
chrono = { version = "0.4", features = ["serde"] }
crc-fast = "1.6"
+7 -11
View File
@@ -437,8 +437,8 @@ impl Cli {
let bs = bytesize::ByteSize::b(size);
tab.push(format!(
"Size:\t{} ({})",
bs.to_string_as(true),
bs.to_string_as(false)
bs.display().si(),
bs.display().iec()
));
tab.push(format!("Size (exact):\t{}", size));
if !ver.blocks.is_empty() {
@@ -488,11 +488,7 @@ fn print_bucket_info(bucket: &GetBucketInfoResponse) {
String::new(),
{
let size = bytesize::ByteSize::b(bucket.bytes as u64);
format!(
"Size:\t{} ({})",
size.to_string_as(true),
size.to_string_as(false)
)
format!("Size:\t{} ({})", size.display().si(), size.display().iec())
},
format!("Objects:\t{}", bucket.objects),
];
@@ -509,8 +505,8 @@ fn print_bucket_info(bucket: &GetBucketInfoResponse) {
bytesize::ByteSize::b(bucket.unfinished_multipart_upload_bytes as u64);
format!(
"Size of unfinished multipart uploads:\t{} ({})",
mpu_size.to_string_as(true),
mpu_size.to_string_as(false),
mpu_size.display().si(),
mpu_size.display().iec(),
)
},
]);
@@ -538,8 +534,8 @@ fn print_bucket_info(bucket: &GetBucketInfoResponse) {
let ms = bytesize::ByteSize::b(ms);
info.push(format!(
" maximum size:\t{} ({})",
ms.to_string_as(true),
ms.to_string_as(false)
ms.display().si(),
ms.display().iec()
));
}
if let Some(mo) = bucket.quotas.max_objects {
+2 -2
View File
@@ -313,7 +313,7 @@ To know the correct value of the new layout version, invoke `garage layout show`
pub fn capacity_string(v: Option<u64>) -> String {
match v {
Some(c) => ByteSize::b(c).to_string_as(false),
Some(c) => ByteSize::b(c).display().iec().to_string(),
None => "gateway".to_string(),
}
}
@@ -383,7 +383,7 @@ pub fn print_cluster_layout(layout: &GetClusterLayoutResponse, empty_msg: &str)
tags,
role.zone,
capacity_string(role.capacity),
ByteSize::b(usable_capacity).to_string_as(false),
ByteSize::b(usable_capacity).display().iec(),
(100.0 * usable_capacity as f32) / (capacity as f32)
));
} else {
+1 -1
View File
@@ -385,7 +385,7 @@ impl Crdt for LayoutStaging {
impl NodeRole {
pub fn capacity_string(&self) -> String {
match self.capacity {
Some(c) => ByteSize::b(c).to_string_as(false),
Some(c) => ByteSize::b(c).display().iec().to_string(),
None => "gateway".to_string(),
}
}
+12 -10
View File
@@ -359,13 +359,13 @@ impl LayoutVersion {
if old_assignment_opt.is_some() {
msg.push(format!(
"Optimal partition size: {} ({} in previous layout)",
ByteSize::b(partition_size).to_string_as(false),
ByteSize::b(self.partition_size).to_string_as(false)
ByteSize::b(partition_size).display().iec(),
ByteSize::b(self.partition_size).display().iec()
));
} else {
msg.push(format!(
"Optimal partition size: {}",
ByteSize::b(partition_size).to_string_as(false)
ByteSize::b(partition_size).display().iec()
));
}
// We write the partition size.
@@ -722,14 +722,16 @@ impl LayoutVersion {
let percent_cap = 100.0 * (used_cap as f32) / (total_cap as f32);
msg.push(format!(
"Usable capacity / total cluster capacity: {} / {} ({:.1} %)",
ByteSize::b(used_cap).to_string_as(false),
ByteSize::b(total_cap).to_string_as(false),
ByteSize::b(used_cap).display().iec(),
ByteSize::b(total_cap).display().iec(),
percent_cap
));
msg.push(format!(
"Effective capacity (replication factor {}): {}",
self.replication_factor,
ByteSize::b(used_cap / self.replication_factor as u64).to_string_as(false)
ByteSize::b(used_cap / self.replication_factor as u64)
.display()
.iec()
));
if percent_cap < 80. {
msg.push("".into());
@@ -838,8 +840,8 @@ impl LayoutVersion {
tags_n,
stored_partitions[*n],
new_partitions[*n],
ByteSize::b(total_cap_n).to_string_as(false),
ByteSize::b(available_cap_n).to_string_as(false),
ByteSize::b(total_cap_n).display().iec(),
ByteSize::b(available_cap_n).display().iec(),
(available_cap_n as f32) / (total_cap_n as f32) * 100.0,
));
}
@@ -849,8 +851,8 @@ impl LayoutVersion {
replicated_partitions,
stored_partitions_zone[z],
//new_partitions_zone[z],
ByteSize::b(total_cap_z).to_string_as(false),
ByteSize::b(available_cap_z).to_string_as(false),
ByteSize::b(total_cap_z).display().iec(),
ByteSize::b(available_cap_z).display().iec(),
percent_cap_z
));
table.push("".into());