This commit is contained in:
2025-11-15 07:51:32 +00:00
parent 69de65ee89
commit 01743c3c75
6 changed files with 24 additions and 512 deletions

View File

@@ -1,21 +1,17 @@
use std::{borrow::Cow, collections::HashMap, sync::LazyLock, time::Instant};
use std::{borrow::Cow, collections::HashMap, time::Instant};
use indicatif::{HumanBytes, ProgressBar};
use owo_colors::{OwoColorize, Style};
use owo_colors::Style;
use crate::{
DONE_CHAR, DOWNLOAD_CHAR, INPROGRESS_CHAR,
action::{Action, ActionType, BuildStepId, ResultFields, StartFields},
download_display::{DOWNLOAD_STYLE, EXTRACT_STYLE, StyledString, style_bar},
estimator::Estimator,
handlers::{Handler, fetch::FetchHandler},
handlers::Handler,
multibar::{BarSegment, MultiBar},
nix_path, pad_string,
};
static DOWNLOAD_CHAR: LazyLock<String> = LazyLock::new(|| "-".blue().bold().to_string());
static DONE_CHAR: LazyLock<String> = LazyLock::new(|| "#".green().bold().to_string());
static INPROGRESS_CHAR: LazyLock<String> = LazyLock::new(|| "-".purple().bold().to_string());
pub struct CopyPathsHandler;
impl Handler for CopyPathsHandler {
@@ -30,7 +26,6 @@ impl Handler for CopyPathsHandler {
id,
..
} => {
state.println(format!("CopyPaths start"))?;
let progress = state.add_pb(ProgressBar::new(1));
progress.set_style(indicatif::ProgressStyle::with_template("{msg}").unwrap());
@@ -103,11 +98,15 @@ impl SubstitutionStatusHandler {
}
let dl_percent = ((self.get_done() as f64 / self.max_transfer as f64) * 100.0) as u64;
let ex_percent = ((self.get_unpacked() as f64 / self.max_copy as f64) * 100.0) as u64;
let expected = (((self.get_running() + self.get_running_copy()) as f64
/ (self.max_transfer + self.max_copy) as f64)
* 100.0) as u64;
let dl_expected_percent =
((self.get_running() as f64 / self.max_transfer as f64) * 100.0) as u64;
let ex_expected_percent =
((self.get_running_copy() as f64 / self.max_copy as f64) * 100.0) as u64;
let min = dl_percent.min(ex_percent);
let dl = dl_percent.saturating_sub(min);
let expected = dl_expected_percent.max(ex_expected_percent);
let exp = expected.saturating_sub(min + dl);
let mbar = MultiBar([
BarSegment::Dynamic(&DONE_CHAR, min),