Add fn add_group() to tasks
Allows for a better tracking of group start and end to update the progress window
This commit is contained in:
parent
a2f61e310f
commit
b06c0db27d
3 changed files with 117 additions and 91 deletions
|
|
@ -400,7 +400,7 @@ 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 title) => {
|
Action::TaskGroupStart(ref title) => {
|
||||||
if self.cur_mode == Mode::BootScan {
|
if self.cur_mode == Mode::BootScan {
|
||||||
info!("TaskGroup: {:?}", self.task_groups.front());
|
info!("TaskGroup: {:?}", self.task_groups.front());
|
||||||
if self.task_groups.front().is_some() {
|
if self.task_groups.front().is_some() {
|
||||||
|
|
@ -608,7 +608,9 @@ impl App {
|
||||||
|
|
||||||
// BCD
|
// BCD
|
||||||
if !letter_boot.is_empty() {
|
if !letter_boot.is_empty() {
|
||||||
self.tasks.add(TaskType::CommandWait(
|
self.tasks.add_group(
|
||||||
|
"Boot Files",
|
||||||
|
vec![TaskType::CommandWait(
|
||||||
PathBuf::from(format!("{}\\bcdedit.exe", &self.system32)),
|
PathBuf::from(format!("{}\\bcdedit.exe", &self.system32)),
|
||||||
vec![
|
vec![
|
||||||
String::from("/store"),
|
String::from("/store"),
|
||||||
|
|
@ -622,37 +624,34 @@ impl App {
|
||||||
),
|
),
|
||||||
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(
|
||||||
|
"Bitlocker",
|
||||||
|
vec![
|
||||||
|
TaskType::CommandWait(
|
||||||
PathBuf::from(format!("{}\\manage-bde.exe", &self.system32)),
|
PathBuf::from(format!("{}\\manage-bde.exe", &self.system32)),
|
||||||
vec![String::from("-status"), format!("{letter_os}:")],
|
vec![String::from("-status"), format!("{letter_os}:")],
|
||||||
));
|
),
|
||||||
self.task_groups.push_back(None);
|
TaskType::CommandWait(
|
||||||
self.tasks.add(TaskType::CommandWait(
|
|
||||||
PathBuf::from(format!("{}\\manage-bde.exe", &self.system32)),
|
PathBuf::from(format!("{}\\manage-bde.exe", &self.system32)),
|
||||||
vec![
|
vec![
|
||||||
String::from("-protectors"),
|
String::from("-protectors"),
|
||||||
String::from("-get"),
|
String::from("-get"),
|
||||||
format!("{letter_os}:"),
|
format!("{letter_os}:"),
|
||||||
],
|
],
|
||||||
));
|
),
|
||||||
self.task_groups
|
],
|
||||||
.push_back(Some(format!("{}", diags::Type::Bitlocker)));
|
);
|
||||||
|
self.task_groups.push_back(Some(String::from("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)",
|
||||||
|
|
@ -662,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(
|
||||||
|
"System Files",
|
||||||
|
vec![TaskType::CommandWait(
|
||||||
PathBuf::from(format!("{}\\dism.exe", &self.system32)),
|
PathBuf::from(format!("{}\\dism.exe", &self.system32)),
|
||||||
vec![format!("{letter_os}:")],
|
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(
|
||||||
|
"Registry",
|
||||||
|
vec![
|
||||||
|
TaskType::CommandWait(
|
||||||
PathBuf::from(format!("{}\\reg.exe", &self.system32)),
|
PathBuf::from(format!("{}\\reg.exe", &self.system32)),
|
||||||
vec![
|
vec![
|
||||||
String::from("load"),
|
String::from("load"),
|
||||||
String::from("HKLM\\TmpSoftware"),
|
String::from("HKLM\\TmpSoftware"),
|
||||||
format!("{letter_os}:\\Windows\\System32\\config\\SOFTWARE"),
|
format!("{letter_os}:\\Windows\\System32\\config\\SOFTWARE"),
|
||||||
],
|
],
|
||||||
));
|
),
|
||||||
self.task_groups.push_back(None);
|
TaskType::CommandWait(
|
||||||
self.tasks.add(TaskType::CommandWait(
|
|
||||||
PathBuf::from(format!("{}\\reg.exe", &self.system32)),
|
PathBuf::from(format!("{}\\reg.exe", &self.system32)),
|
||||||
vec![
|
vec![
|
||||||
String::from("load"),
|
String::from("load"),
|
||||||
String::from("HKLM\\TmpSystem"),
|
String::from("HKLM\\TmpSystem"),
|
||||||
format!("{letter_os}:\\Windows\\System32\\config\\SYSTEM"),
|
format!("{letter_os}:\\Windows\\System32\\config\\SYSTEM"),
|
||||||
],
|
],
|
||||||
));
|
),
|
||||||
self.task_groups.push_back(None);
|
TaskType::CommandWait(
|
||||||
self.tasks.add(TaskType::CommandWait(
|
|
||||||
PathBuf::from(format!("{}\\reg.exe", &self.system32)),
|
PathBuf::from(format!("{}\\reg.exe", &self.system32)),
|
||||||
vec![
|
vec![
|
||||||
String::from("load"),
|
String::from("load"),
|
||||||
String::from("HKU\\TmpDefault"),
|
String::from("HKU\\TmpDefault"),
|
||||||
format!("{letter_os}:\\Windows\\System32\\config\\DEFAULT"),
|
format!("{letter_os}:\\Windows\\System32\\config\\DEFAULT"),
|
||||||
],
|
],
|
||||||
));
|
),
|
||||||
self.task_groups.push_back(None);
|
TaskType::CommandWait(
|
||||||
self.tasks.add(TaskType::CommandWait(
|
|
||||||
PathBuf::from(format!("{}\\reg.exe", &self.system32)),
|
PathBuf::from(format!("{}\\reg.exe", &self.system32)),
|
||||||
vec![String::from("unload"), String::from("HKLM\\TmpSoftware")],
|
vec![String::from("unload"), String::from("HKLM\\TmpSoftware")],
|
||||||
));
|
),
|
||||||
self.task_groups.push_back(None);
|
TaskType::CommandWait(
|
||||||
self.tasks.add(TaskType::CommandWait(
|
|
||||||
PathBuf::from(format!("{}\\reg.exe", &self.system32)),
|
PathBuf::from(format!("{}\\reg.exe", &self.system32)),
|
||||||
vec![String::from("unload"), String::from("HKLM\\TmpSystem")],
|
vec![String::from("unload"), String::from("HKLM\\TmpSystem")],
|
||||||
));
|
),
|
||||||
self.task_groups.push_back(None);
|
TaskType::CommandWait(
|
||||||
self.tasks.add(TaskType::CommandWait(
|
|
||||||
PathBuf::from(format!("{}\\reg.exe", &self.system32)),
|
PathBuf::from(format!("{}\\reg.exe", &self.system32)),
|
||||||
vec![String::from("unload"), String::from("HKU\\TmpDefault")],
|
vec![String::from("unload"), String::from("HKU\\TmpDefault")],
|
||||||
));
|
),
|
||||||
self.task_groups
|
],
|
||||||
.push_back(Some(format!("{}", diags::Type::Registry)));
|
);
|
||||||
|
self.task_groups.push_back(Some(String::from("Registry")));
|
||||||
self.tasks.add(TaskType::Sleep); // NOTE: DELETEME
|
self.tasks.add(TaskType::Sleep); // NOTE: DELETEME
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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(String),
|
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()
|
||||||
|
|
@ -184,8 +199,6 @@ impl Tasks {
|
||||||
cmd_args.clone(),
|
cmd_args.clone(),
|
||||||
task_tx,
|
task_tx,
|
||||||
));
|
));
|
||||||
self.action_tx
|
|
||||||
.send(Action::TaskStart(cmd_path.to_string_lossy().into_owned()))?;
|
|
||||||
}
|
}
|
||||||
TaskType::Diskpart(ref script) => {
|
TaskType::Diskpart(ref script) => {
|
||||||
self.cur_handle = Some(run_task_diskpart(script, task_tx));
|
self.cur_handle = Some(run_task_diskpart(script, task_tx));
|
||||||
|
|
@ -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