fix 0B/s in ProgressBar

This commit is contained in:
Alexander Weiss 2022-12-02 23:55:00 +01:00
parent 1ea300b501
commit cc2d5801df
3 changed files with 4 additions and 12 deletions

11
Cargo.lock generated
View File

@ -1063,13 +1063,12 @@ dependencies = [
[[package]]
name = "indicatif"
version = "0.17.2"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4295cbb7573c16d310e99e713cf9e75101eb190ab31fccd35f2d2691b4352b19"
checksum = "fcc42b206e70d86ec03285b123e65a5458c92027d1fb2ae3555878b8113b3ddf"
dependencies = [
"console",
"number_prefix",
"portable-atomic",
"unicode-width",
]
@ -1415,12 +1414,6 @@ dependencies = [
"universal-hash",
]
[[package]]
name = "portable-atomic"
version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "15eb2c6e362923af47e13c23ca5afb859e83d54452c55b0b9ac763b8f7c1ac16"
[[package]]
name = "ppv-lite86"
version = "0.2.17"

View File

@ -78,7 +78,7 @@ merge = "0.1"
serde_with = "2.1"
rpassword = "7"
bytesize = "1"
indicatif = "0.17"
indicatif = "=0.17.0" # until https://github.com/console-rs/indicatif/issues/493 is fixed.
path-dedot = "3"
gethostname = "0.4"
humantime = "2"

View File

@ -85,8 +85,7 @@ pub fn progress_bytes(prefix: impl Into<Cow<'static, str>>) -> ProgressBar {
ProgressStyle::default_bar()
.with_key("my_eta", |s: &ProgressState, w: &mut dyn Write|
match (s.pos(), s.len()){
(0, _) => write!(w,"-"),
(pos,Some(len)) => write!(w,"{:#}", HumanDuration(Duration::from_secs(s.elapsed().as_secs() * (len-pos)/pos))),
(pos,Some(len)) if pos != 0 => write!(w,"{:#}", HumanDuration(Duration::from_secs(s.elapsed().as_secs() * (len-pos)/pos))),
(_, _) => write!(w,"-"),
}.unwrap())
.template("[{elapsed_precise}] {prefix:30} {bar:40.cyan/blue} {bytes:>10}/{total_bytes:10} {bytes_per_sec:12} (ETA {my_eta})")