Compare commits

..

No commits in common. "081fd22de1099e30ae0e12724407f6454c1f0754" and "7b0deb4cc7467061ef8fccce96e09cd8a5dcbec0" have entirely different histories.

6 changed files with 155 additions and 167 deletions

View file

@ -236,7 +236,7 @@ impl App {
// Late init
self.system32 = if cfg!(windows) {
if let Ok(path) = env::var("SYSTEMROOT") {
format!("{path}\\System32")
format!("{path}/System32")
} else {
self.action_tx.send(Action::Error(String::from(
"ERROR\n\n\nFailed to find SYSTEMROOT",
@ -400,9 +400,19 @@ impl App {
self.action_tx.send(build_right_items(self))?;
self.action_tx.send(Action::Select(None, None))?;
}
Action::TaskGroupStart(ref title) => {
Action::TaskStart(ref task_type) => {
if self.cur_mode == Mode::BootScan {
info!("TaskGroup: {:?}", self.task_groups.front());
let title: Option<String> = match task_type {
TaskType::CommandWait(cmd, _args) => {
let cmd_str = cmd.to_string_lossy().into_owned();
let diag_type = diags::get_type(&cmd_str);
Some(format!("{diag_type}"))
}
TaskType::TestPaths(_) => Some(String::from("Critical Paths")),
_ => 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
@ -413,7 +423,8 @@ impl App {
}
}
if !self.diag_groups.contains(&title) {
self.diag_groups.update(title.to_owned(), None, None);
self.diag_groups.update(title, None, None);
}
}
}
}
@ -523,12 +534,12 @@ impl App {
if passed {
self.action_tx.send(Action::DiagEndLine {
result: DiagResult::Pass,
text: String::from("Pass?"),
text: String::from("Maybe?"),
})?;
} else {
self.action_tx.send(Action::DiagEndLine {
result: DiagResult::Fail,
text: String::from("Fail?"),
text: String::from("Nope?"),
})?;
};
}
@ -537,14 +548,14 @@ impl App {
// If title was set but there wasn't a result
self.action_tx.send(Action::DiagEndLine {
result: DiagResult::Warn,
text: String::from("Yellow no result?"),
text: String::from("Yellow result?"),
})?;
}
} else {
// title was not set
self.action_tx.send(Action::DiagEndLine {
result: DiagResult::Warn,
text: String::from("Yellow no title?"),
text: String::from("Yellow title?"),
})?;
}
}
@ -608,9 +619,7 @@ impl App {
// BCD
if !letter_boot.is_empty() {
self.tasks.add_group(
"Boot Files",
vec![TaskType::CommandWait(
self.tasks.add(TaskType::CommandWait(
PathBuf::from(format!("{}\\bcdedit.exe", &self.system32)),
vec![
String::from("/store"),
@ -624,34 +633,37 @@ impl App {
),
String::from("/enum"),
],
)],
);
self.task_groups.push_back(Some(String::from("Boot Files")));
));
self.task_groups
.push_back(Some(format!("{}", diags::Type::BootConfigData)));
}
// Bitlocker
self.tasks.add_group(
"Bitlocker",
vec![
TaskType::CommandWait(
self.tasks.add(TaskType::CommandWait(
PathBuf::from(format!("{}\\manage-bde.exe", &self.system32)),
vec![String::from("-status"), format!("{letter_os}:")],
),
TaskType::CommandWait(
));
self.task_groups.push_back(None);
self.tasks.add(TaskType::CommandWait(
PathBuf::from(format!("{}\\manage-bde.exe", &self.system32)),
vec![
String::from("-protectors"),
String::from("-get"),
format!("{letter_os}:"),
],
),
],
);
self.task_groups.push_back(Some(String::from("Bitlocker")));
));
self.task_groups
.push_back(Some(format!("{}", diags::Type::Bitlocker)));
// Filesystem Health
let paths: Vec<PathBuf> = [
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> = [
"Users",
"Program Files",
"Program Files (x86)",
@ -661,72 +673,62 @@ impl App {
.iter()
.map(|s| PathBuf::from(format!("{letter_os}:\\{s}")))
.collect();
self.tasks.add_group(
"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")));
self.tasks.add(TaskType::TestPaths(paths));
self.task_groups
.push_back(Some(format!("{}", diags::Type::FileSystem)));
// DISM Health
self.tasks.add_group(
"System Files",
vec![TaskType::CommandWait(
self.tasks.add(TaskType::CommandWait(
PathBuf::from(format!("{}\\dism.exe", &self.system32)),
vec![format!("{letter_os}:")],
)],
);
));
self.task_groups
.push_back(Some(String::from("System Files")));
.push_back(Some(format!("{}", diags::Type::System)));
// Registry
self.tasks.add_group(
"Registry",
vec![
TaskType::CommandWait(
self.tasks.add(TaskType::CommandWait(
PathBuf::from(format!("{}\\reg.exe", &self.system32)),
vec![
String::from("load"),
String::from("HKLM\\TmpSoftware"),
format!("{letter_os}:\\Windows\\System32\\config\\SOFTWARE"),
],
),
TaskType::CommandWait(
));
self.task_groups.push_back(None);
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"),
],
),
TaskType::CommandWait(
));
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"),
],
),
TaskType::CommandWait(
));
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")],
),
TaskType::CommandWait(
));
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")],
),
TaskType::CommandWait(
));
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(String::from("Registry")));
));
self.task_groups
.push_back(Some(format!("{}", diags::Type::Registry)));
self.tasks.add(TaskType::Sleep); // NOTE: DELETEME
}
}
@ -908,7 +910,6 @@ fn build_left_items(app: &App) -> Action {
let (new_title, _) = get_mode_strings(app.cur_mode);
title = new_title;
app.diag_groups.get().iter().for_each(|group| {
info!("BootDiags Group: {:?}", group);
items.push(if group.passed {
group.title.clone()
} else {

View file

@ -21,11 +21,13 @@ use ratatui::{
text::{Line, Span},
widgets::{Block, Borders, Clear, Paragraph},
};
use tokio::sync::mpsc::UnboundedSender;
use tracing::info;
use core::{
action::{Action, DiagResult},
components::Component,
config::Config,
state::Mode,
};
@ -40,12 +42,16 @@ impl ProgressLine {
pub fn len_name(&self) -> usize {
self.name.chars().count()
}
pub fn len_text(&self) -> usize {
self.text.chars().count()
}
}
#[derive(Default, Debug, Clone)]
pub struct Progress {
// command_tx: Option<UnboundedSender<Action>>,
// config: Config,
command_tx: Option<UnboundedSender<Action>>,
config: Config,
lines: Vec<ProgressLine>,
mode: Mode,
}
@ -56,15 +62,15 @@ impl Progress {
Self::default()
}
// fn register_action_handler(&mut self, tx: UnboundedSender<Action>) -> Result<()> {
// self.command_tx = Some(tx);
// Ok(())
// }
fn register_action_handler(&mut self, tx: UnboundedSender<Action>) -> Result<()> {
self.command_tx = Some(tx);
Ok(())
}
// fn register_config_handler(&mut self, config: Config) -> Result<()> {
// self.config = config;
// Ok(())
// }
fn register_config_handler(&mut self, config: Config) -> Result<()> {
self.config = config;
Ok(())
}
}
impl Component for Progress {
@ -79,10 +85,7 @@ impl Component for Progress {
});
}
Action::DiagEndLine { result, text } => {
info!(
"Caught Action::DiagEndLine {{ {}, \"{}\" }}",
&result, &text
);
info!("Caught Action::DiagEndLine");
if let Some(line) = self.lines.last_mut() {
line.result = result;
line.text = text;

View file

@ -15,13 +15,14 @@
//
use color_eyre::Result;
use ratatui::{Frame, layout::Rect};
use tokio::sync::mpsc::UnboundedSender;
use core::{action::Action, components::Component};
use core::{action::Action, components::Component, config::Config};
#[derive(Default, Debug, Clone)]
pub struct Results {
// command_tx: Option<UnboundedSender<Action>>,
// config: Config,
command_tx: Option<UnboundedSender<Action>>,
config: Config,
}
impl Results {
@ -30,23 +31,23 @@ impl Results {
Self::default()
}
// fn register_action_handler(&mut self, tx: UnboundedSender<Action>) -> Result<()> {
// self.command_tx = Some(tx);
// Ok(())
// }
// fn register_config_handler(&mut self, config: Config) -> Result<()> {
// self.config = config;
// Ok(())
// }
}
impl Component for Results {
fn update(&mut self, _action: Action) -> Result<Option<Action>> {
Ok(None)
fn register_action_handler(&mut self, tx: UnboundedSender<Action>) -> Result<()> {
self.command_tx = Some(tx);
Ok(())
}
fn draw(&mut self, _frame: &mut Frame, _area: Rect) -> Result<()> {
fn register_config_handler(&mut self, config: Config) -> Result<()> {
self.config = config;
Ok(())
}
}
impl Component for Results {
fn update(&mut self, action: Action) -> Result<Option<Action>> {
Ok(None)
}
fn draw(&mut self, frame: &mut Frame, area: Rect) -> Result<()> {
Ok(())
}
}

View file

@ -79,7 +79,7 @@ impl Groups {
title.clone(),
Line {
title,
passed: passed.unwrap_or(true),
passed: passed.unwrap_or(false),
info: info_list,
},
);

View file

@ -21,6 +21,7 @@ use crate::{
line::DVLine,
state::Mode,
system::disk::Disk,
tasks::TaskType,
};
#[derive(Debug, Clone, PartialEq, Eq, Display, Serialize, Deserialize)]
@ -43,8 +44,7 @@ pub enum Action {
ScanDisks,
Select(Option<usize>, Option<usize>), // indicies for (source, dest) etc
SelectRight(Option<usize>, Option<usize>), // indicies for right info pane
TaskGroupStart(String),
TaskGroupEnd,
TaskStart(TaskType),
TasksComplete,
UpdateDiskList(Vec<Disk>),
UpdateFooter(String),

View file

@ -52,8 +52,6 @@ pub enum TaskType {
TestPaths(Vec<PathBuf>),
UpdateDestDisk(usize), // (disk_index)
UpdateDiskList,
GroupStart { label: String },
GroupEnd,
}
impl fmt::Display for TaskType {
@ -74,8 +72,6 @@ impl fmt::Display for TaskType {
TaskType::TestPaths(_) => write!(f, "TestPaths"),
TaskType::UpdateDestDisk(_) => write!(f, "UpdateDestDisk"),
TaskType::UpdateDiskList => write!(f, "UpdateDiskList"),
TaskType::GroupStart { label } => write!(f, "GroupStart({})", &label),
TaskType::GroupEnd => write!(f, "GroupEnd"),
}
}
}
@ -131,17 +127,6 @@ impl Tasks {
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]
pub fn idle(&self) -> bool {
self.cur_handle.is_none()
@ -188,6 +173,8 @@ impl Tasks {
self.cur_task = self.task_list.pop_front();
if let Some(task) = self.cur_task.take() {
let task_tx = self.task_tx.clone();
self.action_tx
.send(Action::TaskStart(task.task_type.clone()))?;
match task.task_type {
TaskType::CommandNoWait(ref cmd_path, ref cmd_args) => {
self.cur_handle = None;
@ -248,10 +235,6 @@ impl Tasks {
}
}));
}
TaskType::GroupStart { ref label } => {
self.action_tx.send(Action::TaskGroupStart(label.clone()))?
}
TaskType::GroupEnd => self.action_tx.send(Action::TaskGroupEnd)?,
}
// Done
self.cur_task.replace(task);