Support progress for VerifyPaths.
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -3,3 +3,5 @@
|
||||
/example_logs
|
||||
TODO.org
|
||||
/result
|
||||
/.envrc
|
||||
/.direnv/
|
||||
|
||||
@@ -215,7 +215,15 @@ impl Activity {
|
||||
.as_ref()
|
||||
.map(|phase| Cow::Owned(format!("[{}]", phase))),
|
||||
Activity::OptimizeStore(_activity_optimize_store) => None,
|
||||
Activity::VerifyPaths(_activity_verify_paths) => None,
|
||||
Activity::VerifyPaths(activity_verify_paths) => {
|
||||
get_progress_bar(activity_verify_paths.done, activity_verify_paths.expected)
|
||||
.or_else(|| {
|
||||
get_progress_text(
|
||||
activity_verify_paths.done,
|
||||
activity_verify_paths.expected,
|
||||
)
|
||||
})
|
||||
}
|
||||
Activity::Substitute(_activity_substitute) => None,
|
||||
Activity::QueryPathInfo(_activity_query_path_info) => None,
|
||||
Activity::PostBuildHook(_activity_post_build_hook) => None,
|
||||
@@ -323,8 +331,11 @@ impl Activity {
|
||||
Activity::OptimizeStore(_activity_optimize_store) => {
|
||||
panic!("Attempted to set the progress of an optimize store activity.");
|
||||
}
|
||||
Activity::VerifyPaths(_activity_verify_paths) => {
|
||||
panic!("Attempted to set the progress of a verify paths activity.");
|
||||
Activity::VerifyPaths(activity_verify_paths) => {
|
||||
activity_verify_paths.done = done;
|
||||
activity_verify_paths.expected = expected;
|
||||
activity_verify_paths.running = running;
|
||||
activity_verify_paths.failed = failed;
|
||||
}
|
||||
Activity::Substitute(_activity_substitute) => {
|
||||
panic!("Attempted to set the progress of a substitute activity.");
|
||||
@@ -451,6 +462,10 @@ pub(crate) struct ActivityOptimizeStore {
|
||||
}
|
||||
pub(crate) struct ActivityVerifyPaths {
|
||||
pub(crate) state: ActivityState,
|
||||
pub(crate) done: u64,
|
||||
pub(crate) expected: u64,
|
||||
pub(crate) running: u64,
|
||||
pub(crate) failed: u64,
|
||||
}
|
||||
pub(crate) struct ActivitySubstitute {
|
||||
pub(crate) state: ActivityState,
|
||||
@@ -493,6 +508,23 @@ impl Default for ActivityState {
|
||||
}
|
||||
|
||||
fn get_progress_bar(done: u64, expected: u64) -> Option<Cow<'static, str>> {
|
||||
if expected == 0 {
|
||||
return None;
|
||||
}
|
||||
// ○◔◑◕●
|
||||
// ○◎◉●
|
||||
// ▁▂▃▄▅▆▇█
|
||||
// ▏▎▍▌▋▊▉█
|
||||
// ░▒▓█
|
||||
//
|
||||
// 🮷 download
|
||||
// 🮸 upload
|
||||
// 🮵
|
||||
// 🮶
|
||||
get_progress_bar_clockwise_circle(done, expected)
|
||||
}
|
||||
|
||||
fn get_progress_bar_fade_in(done: u64, expected: u64) -> Option<Cow<'static, str>> {
|
||||
if expected == 0 {
|
||||
return None;
|
||||
}
|
||||
@@ -520,6 +552,36 @@ fn get_progress_bar(done: u64, expected: u64) -> Option<Cow<'static, str>> {
|
||||
}
|
||||
}
|
||||
|
||||
fn get_progress_bar_clockwise_circle(done: u64, expected: u64) -> Option<Cow<'static, str>> {
|
||||
if expected == 0 {
|
||||
return None;
|
||||
}
|
||||
let percent = done as f32 / expected as f32;
|
||||
// ○◔◑◕●
|
||||
// ○◎◉●
|
||||
// ▁▂▃▄▅▆▇█
|
||||
// ▏▎▍▌▋▊▉█
|
||||
// ░▒▓█
|
||||
//
|
||||
// 🮷 download
|
||||
// 🮸 upload
|
||||
// 🮵
|
||||
// 🮶
|
||||
if percent < 0.25 {
|
||||
Some(Cow::Borrowed("○"))
|
||||
} else if percent < 0.5 {
|
||||
Some(Cow::Borrowed("◔"))
|
||||
} else if percent < 0.75 {
|
||||
Some(Cow::Borrowed("◑"))
|
||||
} else if percent < 1.0 {
|
||||
Some(Cow::Borrowed("◕"))
|
||||
} else if percent >= 1.0 {
|
||||
Some(Cow::Borrowed("●"))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
fn get_progress_text(done: u64, expected: u64) -> Option<Cow<'static, str>> {
|
||||
Some(Cow::Owned(format!("[{}/{}]", done, expected)))
|
||||
}
|
||||
|
||||
@@ -163,6 +163,10 @@ impl ActivityTreeStream {
|
||||
activity_start_verify_paths.parent,
|
||||
Activity::VerifyPaths(ActivityVerifyPaths {
|
||||
state: ActivityState::default(),
|
||||
done: 0,
|
||||
expected: 0,
|
||||
running: 0,
|
||||
failed: 0,
|
||||
}),
|
||||
)?;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user