diff --git a/Cargo.lock b/Cargo.lock index 8cfc2158d..495355b3e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1696,9 +1696,12 @@ dependencies = [ [[package]] name = "humansize" -version = "1.1.1" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02296996cb8796d7c6e3bc2d9211b7802812d36999a51bb754123ead7d37d026" +checksum = "4e682e2bd70ecbcce5209f11a992a4ba001fea8e60acf7860ce007629e6d2756" +dependencies = [ + "libm", +] [[package]] name = "humantime" diff --git a/Cargo.toml b/Cargo.toml index aeef4b40f..d24549389 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -74,7 +74,7 @@ toml = "0.5" url = "2" uuid = { version = "1", features = ["serde", "v4"] } fast-socks5 = "0.8" -humansize = "1" +humansize = "2" qrcodegen = "1.7.0" tagger = "4.3.3" textwrap = "0.16.0" diff --git a/src/scheduler/connectivity.rs b/src/scheduler/connectivity.rs index ac2300ad1..a3515daec 100644 --- a/src/scheduler/connectivity.rs +++ b/src/scheduler/connectivity.rs @@ -12,7 +12,7 @@ use crate::tools::time; use crate::{config::Config, scheduler::Scheduler, stock_str, tools}; use crate::{context::Context, log::LogExt}; use anyhow::{anyhow, Result}; -use humansize::{file_size_opts, FileSize}; +use humansize::{format_size, BINARY}; #[derive(Debug, Clone, Copy, PartialEq, Eq, EnumProperty, PartialOrd, Ord)] pub enum Connectivity { @@ -495,12 +495,8 @@ impl Context { // - the string is not longer than the other strings that way (minus title, plus units) - // additional linebreaks on small displays are unlikely therefore // - most times, this is the only item anyway - let usage = (resource.usage * 1024) - .file_size(file_size_opts::BINARY) - .unwrap_or_default(); - let limit = (resource.limit * 1024) - .file_size(file_size_opts::BINARY) - .unwrap_or_default(); + let usage = format_size(resource.usage * 1024, BINARY); + let limit = format_size(resource.limit * 1024, BINARY); stock_str::part_of_total_used(self, usage, limit).await } }; diff --git a/src/stock_str.rs b/src/stock_str.rs index f1b7894db..06b2e952c 100644 --- a/src/stock_str.rs +++ b/src/stock_str.rs @@ -17,7 +17,7 @@ use crate::context::Context; use crate::message::{Message, Viewtype}; use crate::param::Param; use crate::tools::timestamp_to_str; -use humansize::{file_size_opts, FileSize}; +use humansize::{format_size, BINARY}; #[derive(Debug, Clone)] pub struct StockStrings { @@ -1127,9 +1127,7 @@ pub(crate) async fn quota_exceeding(context: &Context, highest_usage: u64) -> St /// Stock string: `%1$s message` with placeholder replaced by human-readable size. pub(crate) async fn partial_download_msg_body(context: &Context, org_bytes: u32) -> String { - let size = org_bytes - .file_size(file_size_opts::BINARY) - .unwrap_or_default(); + let size = format_size(org_bytes, BINARY); translated(context, StockMessage::PartialDownloadMsgBody) .await .replace1(size)