From bc7cce72269e02eba9e9248ab214d3045a90eaf4 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Thu, 8 Dec 2022 01:49:21 -0500 Subject: [PATCH] Open "Target" dir for "Select obj" --- src/jobs/update.rs | 3 +-- src/views/config.rs | 16 ++++++++-------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/jobs/update.rs b/src/jobs/update.rs index ccec51c..2e56f86 100644 --- a/src/jobs/update.rs +++ b/src/jobs/update.rs @@ -1,6 +1,5 @@ use std::{ env::{current_dir, current_exe}, - fs, fs::File, path::PathBuf, sync::mpsc::Receiver, @@ -44,7 +43,7 @@ fn run_update(status: &Status, cancel: Receiver<()>) -> Result .to_dest(&target_file)?; #[cfg(unix)] { - use std::os::unix::fs::PermissionsExt; + use std::{fs, os::unix::fs::PermissionsExt}; let mut perms = fs::metadata(&target_file)?.permissions(); perms.set_mode(0o755); fs::set_permissions(&target_file, perms)?; diff --git a/src/views/config.rs b/src/views/config.rs index d4de4a1..9c8e7bf 100644 --- a/src/views/config.rs +++ b/src/views/config.rs @@ -81,12 +81,14 @@ pub fn config_ui(ui: &mut egui::Ui, config: &Arc>, view_state: if state.update_available { ui.colored_label(Color32::LIGHT_GREEN, "Update available"); ui.horizontal(|ui| { - if state.found_binary && ui + if state.found_binary + && ui .button("Automatic") .on_hover_text_at_pointer( "Automatically download and replace the current build", ) - .clicked() { + .clicked() + { view_state.jobs.push(queue_update()); } if ui @@ -183,20 +185,18 @@ pub fn config_ui(ui: &mut egui::Ui, config: &Arc>, view_state: ui.separator(); } - if let Some(base_dir) = base_obj_dir { + if let (Some(base_dir), Some(target_dir)) = (base_obj_dir, target_obj_dir) { if ui.button("Select obj").clicked() { if let Some(path) = rfd::FileDialog::new() - .set_directory(&base_dir) + .set_directory(&target_dir) .add_filter("Object file", &["o", "elf"]) .pick_file() { let mut new_build_obj: Option = None; if let Ok(obj_path) = path.strip_prefix(&base_dir) { new_build_obj = Some(obj_path.display().to_string()); - } else if let Some(build_asm_dir) = target_obj_dir { - if let Ok(obj_path) = path.strip_prefix(&build_asm_dir) { - new_build_obj = Some(obj_path.display().to_string()); - } + } else if let Ok(obj_path) = path.strip_prefix(&target_dir) { + new_build_obj = Some(obj_path.display().to_string()); } if let Some(new_build_obj) = new_build_obj { *obj_path = Some(new_build_obj);