change color of speed based on whether its finished
This commit is contained in:
@@ -81,6 +81,7 @@ pub struct DownloadHandler {
|
||||
pub id: BuildStepId,
|
||||
pub copy_id: BuildStepId,
|
||||
pub download_estimator: Estimator,
|
||||
pub extract_estimator: Estimator,
|
||||
pub bar: ProgressBar,
|
||||
pub path: String,
|
||||
pub download_expected: u64,
|
||||
@@ -97,6 +98,7 @@ impl DownloadHandler {
|
||||
id: u64::MAX.into(),
|
||||
copy_id,
|
||||
download_estimator: Estimator::new(Instant::now()),
|
||||
extract_estimator: Estimator::new(Instant::now()),
|
||||
bar,
|
||||
path,
|
||||
download_expected: 0,
|
||||
@@ -130,6 +132,8 @@ impl DownloadHandler {
|
||||
|
||||
let download_per_sec =
|
||||
HumanBytes(self.download_estimator.steps_per_second(Instant::now()) as u64).to_string();
|
||||
let extract_per_sec =
|
||||
HumanBytes(self.extract_estimator.steps_per_second(Instant::now()) as u64).to_string();
|
||||
let download_done_human = HumanBytes(self.download_done).to_string();
|
||||
let download_done_human = pad_string(&download_done_human, INFO_WIDTH)
|
||||
.blue()
|
||||
@@ -144,8 +148,17 @@ impl DownloadHandler {
|
||||
.blue()
|
||||
.bold()
|
||||
.to_string();
|
||||
let extract_per_sec = pad_string(&format!("{extract_per_sec}/s"), INFO_WIDTH)
|
||||
.green()
|
||||
.bold()
|
||||
.to_string();
|
||||
let work_per_sec = if self.download_done < self.download_expected {
|
||||
download_per_sec
|
||||
} else {
|
||||
extract_per_sec
|
||||
};
|
||||
|
||||
let display = format!("{download_per_sec} | {download_done_human} | {extract_done_human} ");
|
||||
let display = format!("{work_per_sec} | {download_done_human} | {extract_done_human} ");
|
||||
let display_length = (INFO_WIDTH * 3) + 9;
|
||||
|
||||
// + 6 to account for final format
|
||||
@@ -219,6 +232,7 @@ impl Handler for DownloadHandler {
|
||||
if id == &self.copy_id {
|
||||
self.extract_done = *done;
|
||||
self.extract_expected = *expected;
|
||||
self.extract_estimator.record(*done, Instant::now());
|
||||
self.draw_bar(state.term_width);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user