Compare commits
3 commits
7b0deb4cc7
...
081fd22de1
| Author | SHA1 | Date | |
|---|---|---|---|
| 081fd22de1 | |||
| b06c0db27d | |||
| a2f61e310f |
6 changed files with 162 additions and 150 deletions
|
|
@ -236,7 +236,7 @@ impl App {
|
||||||
// Late init
|
// Late init
|
||||||
self.system32 = if cfg!(windows) {
|
self.system32 = if cfg!(windows) {
|
||||||
if let Ok(path) = env::var("SYSTEMROOT") {
|
if let Ok(path) = env::var("SYSTEMROOT") {
|
||||||
format!("{path}/System32")
|
format!("{path}\\System32")
|
||||||
} else {
|
} else {
|
||||||
self.action_tx.send(Action::Error(String::from(
|
self.action_tx.send(Action::Error(String::from(
|
||||||
"ERROR\n\n\nFailed to find SYSTEMROOT",
|
"ERROR\n\n\nFailed to find SYSTEMROOT",
|
||||||
|
|
@ -400,32 +400,21 @@ impl App {
|
||||||
self.action_tx.send(build_right_items(self))?;
|
self.action_tx.send(build_right_items(self))?;
|
||||||
self.action_tx.send(Action::Select(None, None))?;
|
self.action_tx.send(Action::Select(None, None))?;
|
||||||
}
|
}
|
||||||
Action::TaskStart(ref task_type) => {
|
Action::TaskGroupStart(ref title) => {
|
||||||
if self.cur_mode == Mode::BootScan {
|
if self.cur_mode == Mode::BootScan {
|
||||||
let title: Option<String> = match task_type {
|
info!("TaskGroup: {:?}", self.task_groups.front());
|
||||||
TaskType::CommandWait(cmd, _args) => {
|
if self.task_groups.front().is_some() {
|
||||||
let cmd_str = cmd.to_string_lossy().into_owned();
|
if self.task_groups.front().unwrap().is_some() {
|
||||||
let diag_type = diags::get_type(&cmd_str);
|
// None here means that we're in the middle of a group of tasks
|
||||||
Some(format!("{diag_type}"))
|
// i.e. don't start a new diag line
|
||||||
}
|
self.action_tx.send(Action::DiagStartLine {
|
||||||
TaskType::TestPaths(_) => Some(String::from("Critical Paths")),
|
text: title.clone(),
|
||||||
_ => None,
|
})?;
|
||||||
};
|
|
||||||
if let Some(title) = title {
|
|
||||||
info!("{:?}", self.task_groups.front());
|
|
||||||
if self.task_groups.front().is_some() {
|
|
||||||
if self.task_groups.front().unwrap().is_some() {
|
|
||||||
// None here means that we're in the middle of a group of tasks
|
|
||||||
// i.e. don't start a new diag line
|
|
||||||
self.action_tx.send(Action::DiagStartLine {
|
|
||||||
text: title.clone(),
|
|
||||||
})?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !self.diag_groups.contains(&title) {
|
|
||||||
self.diag_groups.update(title, None, None);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if !self.diag_groups.contains(&title) {
|
||||||
|
self.diag_groups.update(title.to_owned(), None, None);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Action::TasksComplete => {
|
Action::TasksComplete => {
|
||||||
|
|
@ -534,12 +523,12 @@ impl App {
|
||||||
if passed {
|
if passed {
|
||||||
self.action_tx.send(Action::DiagEndLine {
|
self.action_tx.send(Action::DiagEndLine {
|
||||||
result: DiagResult::Pass,
|
result: DiagResult::Pass,
|
||||||
text: String::from("Maybe?"),
|
text: String::from("Pass?"),
|
||||||
})?;
|
})?;
|
||||||
} else {
|
} else {
|
||||||
self.action_tx.send(Action::DiagEndLine {
|
self.action_tx.send(Action::DiagEndLine {
|
||||||
result: DiagResult::Fail,
|
result: DiagResult::Fail,
|
||||||
text: String::from("Nope?"),
|
text: String::from("Fail?"),
|
||||||
})?;
|
})?;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -548,14 +537,14 @@ impl App {
|
||||||
// If title was set but there wasn't a result
|
// If title was set but there wasn't a result
|
||||||
self.action_tx.send(Action::DiagEndLine {
|
self.action_tx.send(Action::DiagEndLine {
|
||||||
result: DiagResult::Warn,
|
result: DiagResult::Warn,
|
||||||
text: String::from("Yellow result?"),
|
text: String::from("Yellow no result?"),
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// title was not set
|
// title was not set
|
||||||
self.action_tx.send(Action::DiagEndLine {
|
self.action_tx.send(Action::DiagEndLine {
|
||||||
result: DiagResult::Warn,
|
result: DiagResult::Warn,
|
||||||
text: String::from("Yellow title?"),
|
text: String::from("Yellow no title?"),
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -619,51 +608,50 @@ impl App {
|
||||||
|
|
||||||
// BCD
|
// BCD
|
||||||
if !letter_boot.is_empty() {
|
if !letter_boot.is_empty() {
|
||||||
self.tasks.add(TaskType::CommandWait(
|
self.tasks.add_group(
|
||||||
PathBuf::from(format!("{}\\bcdedit.exe", &self.system32)),
|
"Boot Files",
|
||||||
vec![
|
vec![TaskType::CommandWait(
|
||||||
String::from("/store"),
|
PathBuf::from(format!("{}\\bcdedit.exe", &self.system32)),
|
||||||
format!(
|
vec![
|
||||||
"{letter_boot}:{}\\Boot\\BCD",
|
String::from("/store"),
|
||||||
if table_type == PartitionTableType::Guid {
|
format!(
|
||||||
"\\EFI\\Microsoft"
|
"{letter_boot}:{}\\Boot\\BCD",
|
||||||
} else {
|
if table_type == PartitionTableType::Guid {
|
||||||
""
|
"\\EFI\\Microsoft"
|
||||||
}
|
} else {
|
||||||
),
|
""
|
||||||
String::from("/enum"),
|
}
|
||||||
],
|
),
|
||||||
));
|
String::from("/enum"),
|
||||||
self.task_groups
|
],
|
||||||
.push_back(Some(format!("{}", diags::Type::BootConfigData)));
|
)],
|
||||||
|
);
|
||||||
|
self.task_groups.push_back(Some(String::from("Boot Files")));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bitlocker
|
// Bitlocker
|
||||||
self.tasks.add(TaskType::CommandWait(
|
self.tasks.add_group(
|
||||||
PathBuf::from(format!("{}\\manage-bde.exe", &self.system32)),
|
"Bitlocker",
|
||||||
vec![String::from("-status"), format!("{letter_os}:")],
|
|
||||||
));
|
|
||||||
self.task_groups.push_back(None);
|
|
||||||
self.tasks.add(TaskType::CommandWait(
|
|
||||||
PathBuf::from(format!("{}\\manage-bde.exe", &self.system32)),
|
|
||||||
vec![
|
vec![
|
||||||
String::from("-protectors"),
|
TaskType::CommandWait(
|
||||||
String::from("-get"),
|
PathBuf::from(format!("{}\\manage-bde.exe", &self.system32)),
|
||||||
format!("{letter_os}:"),
|
vec![String::from("-status"), format!("{letter_os}:")],
|
||||||
|
),
|
||||||
|
TaskType::CommandWait(
|
||||||
|
PathBuf::from(format!("{}\\manage-bde.exe", &self.system32)),
|
||||||
|
vec![
|
||||||
|
String::from("-protectors"),
|
||||||
|
String::from("-get"),
|
||||||
|
format!("{letter_os}:"),
|
||||||
|
],
|
||||||
|
),
|
||||||
],
|
],
|
||||||
));
|
);
|
||||||
self.task_groups
|
self.task_groups.push_back(Some(String::from("Bitlocker")));
|
||||||
.push_back(Some(format!("{}", diags::Type::Bitlocker)));
|
|
||||||
|
|
||||||
// Filesystem Health
|
// Filesystem Health
|
||||||
self.tasks.add(TaskType::CommandWait(
|
|
||||||
PathBuf::from(format!("{}\\chkdsk.exe", &self.system32)),
|
|
||||||
vec![format!("{letter_os}:")],
|
|
||||||
));
|
|
||||||
self.task_groups.push_back(None);
|
|
||||||
|
|
||||||
// Files/Folders
|
|
||||||
let paths: Vec<PathBuf> = [
|
let paths: Vec<PathBuf> = [
|
||||||
|
// Files/Folders
|
||||||
"Users",
|
"Users",
|
||||||
"Program Files",
|
"Program Files",
|
||||||
"Program Files (x86)",
|
"Program Files (x86)",
|
||||||
|
|
@ -673,62 +661,72 @@ impl App {
|
||||||
.iter()
|
.iter()
|
||||||
.map(|s| PathBuf::from(format!("{letter_os}:\\{s}")))
|
.map(|s| PathBuf::from(format!("{letter_os}:\\{s}")))
|
||||||
.collect();
|
.collect();
|
||||||
self.tasks.add(TaskType::TestPaths(paths));
|
self.tasks.add_group(
|
||||||
self.task_groups
|
"Filesystem",
|
||||||
.push_back(Some(format!("{}", diags::Type::FileSystem)));
|
vec![
|
||||||
|
TaskType::CommandWait(
|
||||||
|
PathBuf::from(format!("{}\\chkdsk.exe", &self.system32)),
|
||||||
|
vec![format!("{letter_os}:")],
|
||||||
|
),
|
||||||
|
TaskType::TestPaths(paths),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
self.task_groups.push_back(Some(String::from("Filesystem")));
|
||||||
|
|
||||||
// DISM Health
|
// DISM Health
|
||||||
self.tasks.add(TaskType::CommandWait(
|
self.tasks.add_group(
|
||||||
PathBuf::from(format!("{}\\dism.exe", &self.system32)),
|
"System Files",
|
||||||
vec![format!("{letter_os}:")],
|
vec![TaskType::CommandWait(
|
||||||
));
|
PathBuf::from(format!("{}\\dism.exe", &self.system32)),
|
||||||
|
vec![format!("{letter_os}:")],
|
||||||
|
)],
|
||||||
|
);
|
||||||
self.task_groups
|
self.task_groups
|
||||||
.push_back(Some(format!("{}", diags::Type::System)));
|
.push_back(Some(String::from("System Files")));
|
||||||
|
|
||||||
// Registry
|
// Registry
|
||||||
self.tasks.add(TaskType::CommandWait(
|
self.tasks.add_group(
|
||||||
PathBuf::from(format!("{}\\reg.exe", &self.system32)),
|
"Registry",
|
||||||
vec![
|
vec![
|
||||||
String::from("load"),
|
TaskType::CommandWait(
|
||||||
String::from("HKLM\\TmpSoftware"),
|
PathBuf::from(format!("{}\\reg.exe", &self.system32)),
|
||||||
format!("{letter_os}:\\Windows\\System32\\config\\SOFTWARE"),
|
vec![
|
||||||
|
String::from("load"),
|
||||||
|
String::from("HKLM\\TmpSoftware"),
|
||||||
|
format!("{letter_os}:\\Windows\\System32\\config\\SOFTWARE"),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
TaskType::CommandWait(
|
||||||
|
PathBuf::from(format!("{}\\reg.exe", &self.system32)),
|
||||||
|
vec![
|
||||||
|
String::from("load"),
|
||||||
|
String::from("HKLM\\TmpSystem"),
|
||||||
|
format!("{letter_os}:\\Windows\\System32\\config\\SYSTEM"),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
TaskType::CommandWait(
|
||||||
|
PathBuf::from(format!("{}\\reg.exe", &self.system32)),
|
||||||
|
vec![
|
||||||
|
String::from("load"),
|
||||||
|
String::from("HKU\\TmpDefault"),
|
||||||
|
format!("{letter_os}:\\Windows\\System32\\config\\DEFAULT"),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
TaskType::CommandWait(
|
||||||
|
PathBuf::from(format!("{}\\reg.exe", &self.system32)),
|
||||||
|
vec![String::from("unload"), String::from("HKLM\\TmpSoftware")],
|
||||||
|
),
|
||||||
|
TaskType::CommandWait(
|
||||||
|
PathBuf::from(format!("{}\\reg.exe", &self.system32)),
|
||||||
|
vec![String::from("unload"), String::from("HKLM\\TmpSystem")],
|
||||||
|
),
|
||||||
|
TaskType::CommandWait(
|
||||||
|
PathBuf::from(format!("{}\\reg.exe", &self.system32)),
|
||||||
|
vec![String::from("unload"), String::from("HKU\\TmpDefault")],
|
||||||
|
),
|
||||||
],
|
],
|
||||||
));
|
);
|
||||||
self.task_groups.push_back(None);
|
self.task_groups.push_back(Some(String::from("Registry")));
|
||||||
self.tasks.add(TaskType::CommandWait(
|
|
||||||
PathBuf::from(format!("{}\\reg.exe", &self.system32)),
|
|
||||||
vec![
|
|
||||||
String::from("load"),
|
|
||||||
String::from("HKLM\\TmpSystem"),
|
|
||||||
format!("{letter_os}:\\Windows\\System32\\config\\SYSTEM"),
|
|
||||||
],
|
|
||||||
));
|
|
||||||
self.task_groups.push_back(None);
|
|
||||||
self.tasks.add(TaskType::CommandWait(
|
|
||||||
PathBuf::from(format!("{}\\reg.exe", &self.system32)),
|
|
||||||
vec![
|
|
||||||
String::from("load"),
|
|
||||||
String::from("HKU\\TmpDefault"),
|
|
||||||
format!("{letter_os}:\\Windows\\System32\\config\\DEFAULT"),
|
|
||||||
],
|
|
||||||
));
|
|
||||||
self.task_groups.push_back(None);
|
|
||||||
self.tasks.add(TaskType::CommandWait(
|
|
||||||
PathBuf::from(format!("{}\\reg.exe", &self.system32)),
|
|
||||||
vec![String::from("unload"), String::from("HKLM\\TmpSoftware")],
|
|
||||||
));
|
|
||||||
self.task_groups.push_back(None);
|
|
||||||
self.tasks.add(TaskType::CommandWait(
|
|
||||||
PathBuf::from(format!("{}\\reg.exe", &self.system32)),
|
|
||||||
vec![String::from("unload"), String::from("HKLM\\TmpSystem")],
|
|
||||||
));
|
|
||||||
self.task_groups.push_back(None);
|
|
||||||
self.tasks.add(TaskType::CommandWait(
|
|
||||||
PathBuf::from(format!("{}\\reg.exe", &self.system32)),
|
|
||||||
vec![String::from("unload"), String::from("HKU\\TmpDefault")],
|
|
||||||
));
|
|
||||||
self.task_groups
|
|
||||||
.push_back(Some(format!("{}", diags::Type::Registry)));
|
|
||||||
self.tasks.add(TaskType::Sleep); // NOTE: DELETEME
|
self.tasks.add(TaskType::Sleep); // NOTE: DELETEME
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -910,6 +908,7 @@ fn build_left_items(app: &App) -> Action {
|
||||||
let (new_title, _) = get_mode_strings(app.cur_mode);
|
let (new_title, _) = get_mode_strings(app.cur_mode);
|
||||||
title = new_title;
|
title = new_title;
|
||||||
app.diag_groups.get().iter().for_each(|group| {
|
app.diag_groups.get().iter().for_each(|group| {
|
||||||
|
info!("BootDiags Group: {:?}", group);
|
||||||
items.push(if group.passed {
|
items.push(if group.passed {
|
||||||
group.title.clone()
|
group.title.clone()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,11 @@ use ratatui::{
|
||||||
text::{Line, Span},
|
text::{Line, Span},
|
||||||
widgets::{Block, Borders, Clear, Paragraph},
|
widgets::{Block, Borders, Clear, Paragraph},
|
||||||
};
|
};
|
||||||
use tokio::sync::mpsc::UnboundedSender;
|
|
||||||
use tracing::info;
|
use tracing::info;
|
||||||
|
|
||||||
use core::{
|
use core::{
|
||||||
action::{Action, DiagResult},
|
action::{Action, DiagResult},
|
||||||
components::Component,
|
components::Component,
|
||||||
config::Config,
|
|
||||||
state::Mode,
|
state::Mode,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -42,16 +40,12 @@ impl ProgressLine {
|
||||||
pub fn len_name(&self) -> usize {
|
pub fn len_name(&self) -> usize {
|
||||||
self.name.chars().count()
|
self.name.chars().count()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn len_text(&self) -> usize {
|
|
||||||
self.text.chars().count()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Debug, Clone)]
|
#[derive(Default, Debug, Clone)]
|
||||||
pub struct Progress {
|
pub struct Progress {
|
||||||
command_tx: Option<UnboundedSender<Action>>,
|
// command_tx: Option<UnboundedSender<Action>>,
|
||||||
config: Config,
|
// config: Config,
|
||||||
lines: Vec<ProgressLine>,
|
lines: Vec<ProgressLine>,
|
||||||
mode: Mode,
|
mode: Mode,
|
||||||
}
|
}
|
||||||
|
|
@ -62,15 +56,15 @@ impl Progress {
|
||||||
Self::default()
|
Self::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn register_action_handler(&mut self, tx: UnboundedSender<Action>) -> Result<()> {
|
// fn register_action_handler(&mut self, tx: UnboundedSender<Action>) -> Result<()> {
|
||||||
self.command_tx = Some(tx);
|
// self.command_tx = Some(tx);
|
||||||
Ok(())
|
// Ok(())
|
||||||
}
|
// }
|
||||||
|
|
||||||
fn register_config_handler(&mut self, config: Config) -> Result<()> {
|
// fn register_config_handler(&mut self, config: Config) -> Result<()> {
|
||||||
self.config = config;
|
// self.config = config;
|
||||||
Ok(())
|
// Ok(())
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Component for Progress {
|
impl Component for Progress {
|
||||||
|
|
@ -85,7 +79,10 @@ impl Component for Progress {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Action::DiagEndLine { result, text } => {
|
Action::DiagEndLine { result, text } => {
|
||||||
info!("Caught Action::DiagEndLine");
|
info!(
|
||||||
|
"Caught Action::DiagEndLine {{ {}, \"{}\" }}",
|
||||||
|
&result, &text
|
||||||
|
);
|
||||||
if let Some(line) = self.lines.last_mut() {
|
if let Some(line) = self.lines.last_mut() {
|
||||||
line.result = result;
|
line.result = result;
|
||||||
line.text = text;
|
line.text = text;
|
||||||
|
|
|
||||||
|
|
@ -15,14 +15,13 @@
|
||||||
//
|
//
|
||||||
use color_eyre::Result;
|
use color_eyre::Result;
|
||||||
use ratatui::{Frame, layout::Rect};
|
use ratatui::{Frame, layout::Rect};
|
||||||
use tokio::sync::mpsc::UnboundedSender;
|
|
||||||
|
|
||||||
use core::{action::Action, components::Component, config::Config};
|
use core::{action::Action, components::Component};
|
||||||
|
|
||||||
#[derive(Default, Debug, Clone)]
|
#[derive(Default, Debug, Clone)]
|
||||||
pub struct Results {
|
pub struct Results {
|
||||||
command_tx: Option<UnboundedSender<Action>>,
|
// command_tx: Option<UnboundedSender<Action>>,
|
||||||
config: Config,
|
// config: Config,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Results {
|
impl Results {
|
||||||
|
|
@ -31,23 +30,23 @@ impl Results {
|
||||||
Self::default()
|
Self::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn register_action_handler(&mut self, tx: UnboundedSender<Action>) -> Result<()> {
|
// fn register_action_handler(&mut self, tx: UnboundedSender<Action>) -> Result<()> {
|
||||||
self.command_tx = Some(tx);
|
// self.command_tx = Some(tx);
|
||||||
Ok(())
|
// Ok(())
|
||||||
}
|
// }
|
||||||
|
|
||||||
fn register_config_handler(&mut self, config: Config) -> Result<()> {
|
// fn register_config_handler(&mut self, config: Config) -> Result<()> {
|
||||||
self.config = config;
|
// self.config = config;
|
||||||
Ok(())
|
// Ok(())
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Component for Results {
|
impl Component for Results {
|
||||||
fn update(&mut self, action: Action) -> Result<Option<Action>> {
|
fn update(&mut self, _action: Action) -> Result<Option<Action>> {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw(&mut self, frame: &mut Frame, area: Rect) -> Result<()> {
|
fn draw(&mut self, _frame: &mut Frame, _area: Rect) -> Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ impl Groups {
|
||||||
title.clone(),
|
title.clone(),
|
||||||
Line {
|
Line {
|
||||||
title,
|
title,
|
||||||
passed: passed.unwrap_or(false),
|
passed: passed.unwrap_or(true),
|
||||||
info: info_list,
|
info: info_list,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ use crate::{
|
||||||
line::DVLine,
|
line::DVLine,
|
||||||
state::Mode,
|
state::Mode,
|
||||||
system::disk::Disk,
|
system::disk::Disk,
|
||||||
tasks::TaskType,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Display, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Display, Serialize, Deserialize)]
|
||||||
|
|
@ -44,7 +43,8 @@ pub enum Action {
|
||||||
ScanDisks,
|
ScanDisks,
|
||||||
Select(Option<usize>, Option<usize>), // indicies for (source, dest) etc
|
Select(Option<usize>, Option<usize>), // indicies for (source, dest) etc
|
||||||
SelectRight(Option<usize>, Option<usize>), // indicies for right info pane
|
SelectRight(Option<usize>, Option<usize>), // indicies for right info pane
|
||||||
TaskStart(TaskType),
|
TaskGroupStart(String),
|
||||||
|
TaskGroupEnd,
|
||||||
TasksComplete,
|
TasksComplete,
|
||||||
UpdateDiskList(Vec<Disk>),
|
UpdateDiskList(Vec<Disk>),
|
||||||
UpdateFooter(String),
|
UpdateFooter(String),
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,8 @@ pub enum TaskType {
|
||||||
TestPaths(Vec<PathBuf>),
|
TestPaths(Vec<PathBuf>),
|
||||||
UpdateDestDisk(usize), // (disk_index)
|
UpdateDestDisk(usize), // (disk_index)
|
||||||
UpdateDiskList,
|
UpdateDiskList,
|
||||||
|
GroupStart { label: String },
|
||||||
|
GroupEnd,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for TaskType {
|
impl fmt::Display for TaskType {
|
||||||
|
|
@ -72,6 +74,8 @@ impl fmt::Display for TaskType {
|
||||||
TaskType::TestPaths(_) => write!(f, "TestPaths"),
|
TaskType::TestPaths(_) => write!(f, "TestPaths"),
|
||||||
TaskType::UpdateDestDisk(_) => write!(f, "UpdateDestDisk"),
|
TaskType::UpdateDestDisk(_) => write!(f, "UpdateDestDisk"),
|
||||||
TaskType::UpdateDiskList => write!(f, "UpdateDiskList"),
|
TaskType::UpdateDiskList => write!(f, "UpdateDiskList"),
|
||||||
|
TaskType::GroupStart { label } => write!(f, "GroupStart({})", &label),
|
||||||
|
TaskType::GroupEnd => write!(f, "GroupEnd"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -127,6 +131,17 @@ impl Tasks {
|
||||||
self.task_list.push_back(Task::new(task_type));
|
self.task_list.push_back(Task::new(task_type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn add_group(&mut self, group_label: &str, group_tasks: Vec<TaskType>) {
|
||||||
|
info!("Adding task group: {group_label}");
|
||||||
|
self.task_list.push_back(Task::new(TaskType::GroupStart {
|
||||||
|
label: group_label.to_string(),
|
||||||
|
}));
|
||||||
|
group_tasks.into_iter().for_each(|task| {
|
||||||
|
self.task_list.push_back(Task::new(task));
|
||||||
|
});
|
||||||
|
self.task_list.push_back(Task::new(TaskType::GroupEnd));
|
||||||
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn idle(&self) -> bool {
|
pub fn idle(&self) -> bool {
|
||||||
self.cur_handle.is_none()
|
self.cur_handle.is_none()
|
||||||
|
|
@ -173,8 +188,6 @@ impl Tasks {
|
||||||
self.cur_task = self.task_list.pop_front();
|
self.cur_task = self.task_list.pop_front();
|
||||||
if let Some(task) = self.cur_task.take() {
|
if let Some(task) = self.cur_task.take() {
|
||||||
let task_tx = self.task_tx.clone();
|
let task_tx = self.task_tx.clone();
|
||||||
self.action_tx
|
|
||||||
.send(Action::TaskStart(task.task_type.clone()))?;
|
|
||||||
match task.task_type {
|
match task.task_type {
|
||||||
TaskType::CommandNoWait(ref cmd_path, ref cmd_args) => {
|
TaskType::CommandNoWait(ref cmd_path, ref cmd_args) => {
|
||||||
self.cur_handle = None;
|
self.cur_handle = None;
|
||||||
|
|
@ -235,6 +248,10 @@ impl Tasks {
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
TaskType::GroupStart { ref label } => {
|
||||||
|
self.action_tx.send(Action::TaskGroupStart(label.clone()))?
|
||||||
|
}
|
||||||
|
TaskType::GroupEnd => self.action_tx.send(Action::TaskGroupEnd)?,
|
||||||
}
|
}
|
||||||
// Done
|
// Done
|
||||||
self.cur_task.replace(task);
|
self.cur_task.replace(task);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue