Compare commits
4 commits
09b204c0b0
...
c4c174b546
| Author | SHA1 | Date | |
|---|---|---|---|
| c4c174b546 | |||
| 4658624988 | |||
| c572716ef9 | |||
| e873ec9602 |
4 changed files with 51 additions and 28 deletions
|
|
@ -211,6 +211,7 @@
|
|||
"<Enter>": "Process",
|
||||
"<Up>": "KeyUp",
|
||||
"<Down>": "KeyDown",
|
||||
"<b>": "PrevScreen",
|
||||
"<q>": "Quit",
|
||||
"<Ctrl-d>": "Quit",
|
||||
"<Ctrl-c>": "Quit",
|
||||
|
|
|
|||
|
|
@ -109,19 +109,7 @@ impl App {
|
|||
Mode::SelectTableType => Mode::ScanWinSources,
|
||||
Mode::ScanWinSources => Mode::SelectWinSource,
|
||||
Mode::SelectWinSource => Mode::SelectWinImage,
|
||||
Mode::SelectWinImage => {
|
||||
let mut next_mode = Mode::SetUserName;
|
||||
// TODO: FIXME - Race condition?
|
||||
// if let Ok(wim_sources) = self.state.wim_sources.lock()
|
||||
// && let Some(index) = self.state.wim_image_index
|
||||
// {
|
||||
// let image = wim_sources.get_file(index);
|
||||
// if !image.is_installer {
|
||||
// next_mode = Mode::Confirm;
|
||||
// }
|
||||
// }
|
||||
next_mode
|
||||
}
|
||||
Mode::SelectWinImage => Mode::SetUserName,
|
||||
Mode::SetUserName => Mode::Confirm,
|
||||
Mode::Confirm => Mode::Process, // i.e. format, apply, etc
|
||||
Mode::Process | Mode::Done => Mode::Done,
|
||||
|
|
@ -161,7 +149,20 @@ impl App {
|
|||
String::from("Scanning Disks..."),
|
||||
))?;
|
||||
}
|
||||
Mode::ScanWinSources => self.state.scan_wim_local(ScanType::WindowsInstallers),
|
||||
Mode::ScanWinSources => {
|
||||
self.state.reset_all();
|
||||
self.state.scan_wim_local(ScanType::WindowsInstallers);
|
||||
}
|
||||
Mode::SetUserName => {
|
||||
if let Ok(wim_sources) = self.state.wim_sources.lock()
|
||||
&& let Some(index) = self.state.wim_image_index
|
||||
{
|
||||
let image = wim_sources.get_file(index);
|
||||
if !image.is_setup {
|
||||
self.action_tx.send(Action::NextScreen)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
Mode::Done => {
|
||||
self.action_tx
|
||||
.send(Action::DisplayPopup(popup::Type::Success, popup::fortune()))?;
|
||||
|
|
@ -429,7 +430,7 @@ fn build_footer_string(cur_mode: Mode) -> String {
|
|||
),
|
||||
Mode::SelectTableType => String::from("(Enter) to select / (b) to go back / (q) to quit"),
|
||||
Mode::SelectWinSource | Mode::SelectWinImage => {
|
||||
String::from("(Enter) to select / (q) to quit")
|
||||
String::from("(Enter) to select / (b) to go back / (q) to quit")
|
||||
}
|
||||
Mode::ScanWinSources => String::from(
|
||||
"(Enter) to continue / (b) to scan for backups / (n) to scan network / (q) to quit",
|
||||
|
|
@ -725,7 +726,7 @@ fn build_right_items(app: &App) -> Action {
|
|||
DVLine::blank(),
|
||||
]);
|
||||
}
|
||||
if wim_file.is_installer
|
||||
if wim_file.is_setup
|
||||
&& let Some(username) = &app.state.username
|
||||
{
|
||||
label_dv_lines.append(&mut vec![DVLine {
|
||||
|
|
|
|||
|
|
@ -27,8 +27,6 @@ use core::{
|
|||
},
|
||||
};
|
||||
|
||||
use tracing::info;
|
||||
|
||||
use crate::{
|
||||
net::connect_network_share,
|
||||
wim::{WimFile, WimSources, parse_wim_file},
|
||||
|
|
@ -123,7 +121,7 @@ pub fn scan_local_drives(
|
|||
wim_sources_arc: Arc<Mutex<WimSources>>,
|
||||
scan_type: ScanType,
|
||||
) {
|
||||
let mut to_check = vec![String::from(".")];
|
||||
let mut to_check: Vec<String> = Vec::new();
|
||||
let mut wim_files: Vec<WimFile> = Vec::new();
|
||||
|
||||
// Get drive letters
|
||||
|
|
@ -146,14 +144,13 @@ pub fn scan_local_drives(
|
|||
|
||||
// Scan drives
|
||||
to_check.iter().for_each(|scan_path| {
|
||||
let installer = scan_path.ends_with("\\Images");
|
||||
info!("Scanning: {}", &scan_path);
|
||||
let is_setup = scan_path.ends_with("\\Images");
|
||||
if let Ok(read_dir) = read_dir(scan_path) {
|
||||
read_dir.for_each(|item| {
|
||||
if let Ok(item) = item
|
||||
&& item.file_name().to_string_lossy().ends_with(".wim")
|
||||
&& let Some(path_str) = item.path().to_str()
|
||||
&& let Ok(new_source) = parse_wim_file(path_str, installer)
|
||||
&& let Ok(new_source) = parse_wim_file(path_str, is_setup)
|
||||
{
|
||||
wim_files.push(new_source);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
use core::system::disk::bytes_to_string;
|
||||
// This file is part of Deja-Vu.
|
||||
//
|
||||
// Deja-Vu is free software: you can redistribute it and/or modify it
|
||||
|
|
@ -66,7 +67,7 @@ static WIN_BUILDS: LazyLock<HashMap<&str, &str>> = LazyLock::new(|| {
|
|||
pub struct WimFile {
|
||||
pub path: String,
|
||||
pub images: Vec<WimImage>,
|
||||
pub is_installer: bool,
|
||||
pub is_setup: bool,
|
||||
}
|
||||
|
||||
impl WimFile {
|
||||
|
|
@ -112,6 +113,7 @@ pub struct WimImage {
|
|||
pub build: String,
|
||||
pub index: String,
|
||||
pub name: String,
|
||||
pub size: u64,
|
||||
pub spbuild: String,
|
||||
pub version: String,
|
||||
}
|
||||
|
|
@ -138,7 +140,15 @@ impl fmt::Display for WimImage {
|
|||
} else {
|
||||
format!("{}, ", self.version)
|
||||
};
|
||||
write!(f, "{} ({}{}.{})", self.name, s, self.build, self.spbuild)
|
||||
write!(
|
||||
f,
|
||||
"{} ({}{}.{}) [{}]",
|
||||
self.name,
|
||||
s,
|
||||
self.build,
|
||||
self.spbuild,
|
||||
bytes_to_string(self.size)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -206,7 +216,7 @@ fn get_wim_xml(wim_file: &str) -> std::io::Result<File> {
|
|||
Ok(file)
|
||||
}
|
||||
|
||||
pub fn parse_wim_file(wim_file: &str, installer: bool) -> std::io::Result<WimFile> {
|
||||
pub fn parse_wim_file(wim_file: &str, is_setup: bool) -> std::io::Result<WimFile> {
|
||||
let mut wim_images: Vec<WimImage> = Vec::new();
|
||||
if !Path::new(wim_file).exists() {
|
||||
return Err(std::io::Error::new(
|
||||
|
|
@ -249,12 +259,26 @@ pub fn parse_wim_file(wim_file: &str, installer: bool) -> std::io::Result<WimFil
|
|||
if current_element == "SPBUILD" {
|
||||
image.spbuild = char_data.trim().to_string();
|
||||
}
|
||||
if current_element == "TOTALBYTES" {
|
||||
let result = char_data.trim().parse::<u64>();
|
||||
if let Ok(size) = result {
|
||||
image.size = size;
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(XmlEvent::EndElement { name }) => {
|
||||
if name.local_name.to_uppercase() == "IMAGE" {
|
||||
if image.size == 0 {
|
||||
break;
|
||||
}
|
||||
// Append image to list
|
||||
if !image.build.is_empty() && !image.name.is_empty() && !image.index.is_empty()
|
||||
{
|
||||
if image.build.is_empty() {
|
||||
image.build.push('?');
|
||||
}
|
||||
if image.spbuild.is_empty() {
|
||||
image.spbuild.push('?');
|
||||
}
|
||||
if !image.name.is_empty() && !image.index.is_empty() {
|
||||
wim_images.push(image.clone());
|
||||
}
|
||||
|
||||
|
|
@ -271,7 +295,7 @@ pub fn parse_wim_file(wim_file: &str, installer: bool) -> std::io::Result<WimFil
|
|||
let wim_file = WimFile {
|
||||
path: wim_file.to_string(),
|
||||
images: wim_images,
|
||||
is_installer: installer,
|
||||
is_setup,
|
||||
};
|
||||
|
||||
Ok(wim_file)
|
||||
|
|
|
|||
Loading…
Reference in a new issue