ProgressBar handling simplification

This commit is contained in:
Jörn-Michael Miehe 2025-06-26 00:08:18 +00:00
parent 3258b8fb74
commit 5adbf8cb38
3 changed files with 4 additions and 8 deletions

View file

@ -1,6 +1,6 @@
use std::{fmt, io, time::Duration};
use indicatif::{ProgressBar, ProgressDrawTarget};
use indicatif::ProgressBar;
use log::{debug, warn};
use crate::{
@ -62,7 +62,6 @@ impl AppState {
if let Some(upl) = self.inner.peek_uploading() {
if bar.length().is_none() {
bar.set_draw_target(ProgressDrawTarget::stderr());
bar.set_length(upl.get_size());
bar.set_message(upl.get_name().to_owned());
bar.enable_steady_tick(Duration::from_millis(100));
@ -70,8 +69,7 @@ impl AppState {
bar.set_position(upl.get_offset());
// BUG in `indicatif` crate?
// `set_position` does not force an immediate redraw, so we also call `inc_length` here
bar.inc_length(0);
// `set_position` does not force an immediate redraw like e.g. `inc_length`
}
f(bar);

View file

@ -6,7 +6,7 @@ use std::{
time::Duration,
};
use indicatif::{ProgressBar, ProgressDrawTarget};
use indicatif::ProgressBar;
use log::{info, trace};
use serde::{Deserialize, Serialize};
@ -87,7 +87,6 @@ impl CacheFile {
};
let bar = new_progressbar();
bar.set_draw_target(ProgressDrawTarget::stderr());
bar.set_length(total_size);
bar.enable_steady_tick(Duration::from_millis(50));
@ -115,7 +114,6 @@ impl CacheFile {
info!("hashing files {files:?}");
let bar = new_progressbar();
bar.set_draw_target(ProgressDrawTarget::stderr());
// BOOKMARK assumption: total file size < 2 EiB
bar.set_length(files.iter().map(FileTrait::get_size).sum());
bar.enable_steady_tick(Duration::from_millis(50));

View file

@ -63,7 +63,7 @@ where
#[must_use]
#[allow(clippy::missing_panics_doc)]
pub fn new_progressbar() -> ProgressBar {
ProgressBar::hidden().with_style(
ProgressBar::no_length().with_style(
ProgressStyle::with_template(&format!(
concat!(
"{{bar:50.cyan/blue}} {{msg:.magenta}}: ",