From 160375f772eab915370dfa71e75236a185dd7097 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Sun, 1 Oct 2023 12:17:11 +0200 Subject: [PATCH] fix: cap percentage in connectivity layout to 100% it may happen that percentages larger than 100% are reported by the provider, eg. for some time a storage usage of 120% may be accepted. while we should report the values "as is" to the user, for the bar, percentages larger 100% will destroy the layout. --- src/scheduler/connectivity.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/scheduler/connectivity.rs b/src/scheduler/connectivity.rs index 472b10001..4d8a66b91 100644 --- a/src/scheduler/connectivity.rs +++ b/src/scheduler/connectivity.rs @@ -1,4 +1,5 @@ use core::fmt; +use std::cmp::min; use std::{iter::once, ops::Deref, sync::Arc}; use anyhow::{anyhow, Result}; @@ -457,7 +458,8 @@ impl Context { } else { "green" }; - ret += &format!("
{percent}%
"); + let div_width_percent = min(100, percent); + ret += &format!("
{percent}%
"); ret += ""; }