mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
don't show "Bytes" for overall progress
This commit is contained in:
@@ -18,7 +18,9 @@ use crate::prelude::*;
|
|||||||
|
|
||||||
lazy_static::lazy_static! {
|
lazy_static::lazy_static! {
|
||||||
static ref SPINNER: ProgressStyle = ProgressStyle::with_template("{spinner} {msg}...").unwrap();
|
static ref SPINNER: ProgressStyle = ProgressStyle::with_template("{spinner} {msg}...").unwrap();
|
||||||
static ref PERCENTAGE: ProgressStyle = ProgressStyle::with_template("{msg} {percent}% {wide_bar} [{bytes}/{total_bytes}] [{binary_bytes_per_sec} {eta}]").unwrap();
|
static ref PERCENTAGE: ProgressStyle = ProgressStyle::with_template("{msg} {percent}% {wide_bar} [{human_pos}/{human_len}] [{per_sec} {eta}]").unwrap();
|
||||||
|
static ref PERCENTAGE_BYTES: ProgressStyle = ProgressStyle::with_template("{msg} {percent}% {wide_bar} [{binary_bytes}/{binary_total_bytes}] [{binary_bytes_per_sec} {eta}]").unwrap();
|
||||||
|
static ref STEPS: ProgressStyle = ProgressStyle::with_template("{spinner} {wide_msg} [{human_pos}/?] [{per_sec} {elapsed}]").unwrap();
|
||||||
static ref BYTES: ProgressStyle = ProgressStyle::with_template("{spinner} {wide_msg} [{bytes}/?] [{binary_bytes_per_sec} {elapsed}]").unwrap();
|
static ref BYTES: ProgressStyle = ProgressStyle::with_template("{spinner} {wide_msg} [{bytes}/?] [{binary_bytes_per_sec} {elapsed}]").unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,7 +40,7 @@ impl Progress {
|
|||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Progress::NotStarted(())
|
Progress::NotStarted(())
|
||||||
}
|
}
|
||||||
pub fn update_bar(self, bar: &ProgressBar) {
|
pub fn update_bar(self, bar: &ProgressBar, bytes: bool) {
|
||||||
match self {
|
match self {
|
||||||
Self::NotStarted(()) => {
|
Self::NotStarted(()) => {
|
||||||
bar.set_style(SPINNER.clone());
|
bar.set_style(SPINNER.clone());
|
||||||
@@ -51,7 +53,11 @@ impl Progress {
|
|||||||
bar.finish();
|
bar.finish();
|
||||||
}
|
}
|
||||||
Self::Progress { done, total: None } => {
|
Self::Progress { done, total: None } => {
|
||||||
bar.set_style(BYTES.clone());
|
if bytes {
|
||||||
|
bar.set_style(BYTES.clone());
|
||||||
|
} else {
|
||||||
|
bar.set_style(STEPS.clone());
|
||||||
|
}
|
||||||
bar.set_position(done);
|
bar.set_position(done);
|
||||||
bar.tick();
|
bar.tick();
|
||||||
}
|
}
|
||||||
@@ -59,7 +65,11 @@ impl Progress {
|
|||||||
done,
|
done,
|
||||||
total: Some(total),
|
total: Some(total),
|
||||||
} => {
|
} => {
|
||||||
bar.set_style(PERCENTAGE.clone());
|
if bytes {
|
||||||
|
bar.set_style(PERCENTAGE_BYTES.clone());
|
||||||
|
} else {
|
||||||
|
bar.set_style(PERCENTAGE.clone());
|
||||||
|
}
|
||||||
bar.set_position(done);
|
bar.set_position(done);
|
||||||
bar.set_length(total);
|
bar.set_length(total);
|
||||||
bar.tick();
|
bar.tick();
|
||||||
@@ -490,7 +500,7 @@ impl PhasedProgressBar {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
progress.overall.update_bar(&self.overall);
|
progress.overall.update_bar(&self.overall, false);
|
||||||
for (name, bar) in self.phases.iter() {
|
for (name, bar) in self.phases.iter() {
|
||||||
if let Some(progress) = progress.phases.iter().find_map(|p| {
|
if let Some(progress) = progress.phases.iter().find_map(|p| {
|
||||||
if &p.name == name {
|
if &p.name == name {
|
||||||
@@ -499,7 +509,7 @@ impl PhasedProgressBar {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
}) {
|
}) {
|
||||||
progress.update_bar(bar);
|
progress.update_bar(bar, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user