Skip to content

Commit bc7cce7

Browse files
committed
Open "Target" dir for "Select obj"
1 parent a0371dd commit bc7cce7

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

src/jobs/update.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use std::{
22
env::{current_dir, current_exe},
3-
fs,
43
fs::File,
54
path::PathBuf,
65
sync::mpsc::Receiver,
@@ -44,7 +43,7 @@ fn run_update(status: &Status, cancel: Receiver<()>) -> Result<Box<UpdateResult>
4443
.to_dest(&target_file)?;
4544
#[cfg(unix)]
4645
{
47-
use std::os::unix::fs::PermissionsExt;
46+
use std::{fs, os::unix::fs::PermissionsExt};
4847
let mut perms = fs::metadata(&target_file)?.permissions();
4948
perms.set_mode(0o755);
5049
fs::set_permissions(&target_file, perms)?;

src/views/config.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,14 @@ pub fn config_ui(ui: &mut egui::Ui, config: &Arc<RwLock<AppConfig>>, view_state:
8181
if state.update_available {
8282
ui.colored_label(Color32::LIGHT_GREEN, "Update available");
8383
ui.horizontal(|ui| {
84-
if state.found_binary && ui
84+
if state.found_binary
85+
&& ui
8586
.button("Automatic")
8687
.on_hover_text_at_pointer(
8788
"Automatically download and replace the current build",
8889
)
89-
.clicked() {
90+
.clicked()
91+
{
9092
view_state.jobs.push(queue_update());
9193
}
9294
if ui
@@ -183,20 +185,18 @@ pub fn config_ui(ui: &mut egui::Ui, config: &Arc<RwLock<AppConfig>>, view_state:
183185
ui.separator();
184186
}
185187

186-
if let Some(base_dir) = base_obj_dir {
188+
if let (Some(base_dir), Some(target_dir)) = (base_obj_dir, target_obj_dir) {
187189
if ui.button("Select obj").clicked() {
188190
if let Some(path) = rfd::FileDialog::new()
189-
.set_directory(&base_dir)
191+
.set_directory(&target_dir)
190192
.add_filter("Object file", &["o", "elf"])
191193
.pick_file()
192194
{
193195
let mut new_build_obj: Option<String> = None;
194196
if let Ok(obj_path) = path.strip_prefix(&base_dir) {
195197
new_build_obj = Some(obj_path.display().to_string());
196-
} else if let Some(build_asm_dir) = target_obj_dir {
197-
if let Ok(obj_path) = path.strip_prefix(&build_asm_dir) {
198-
new_build_obj = Some(obj_path.display().to_string());
199-
}
198+
} else if let Ok(obj_path) = path.strip_prefix(&target_dir) {
199+
new_build_obj = Some(obj_path.display().to_string());
200200
}
201201
if let Some(new_build_obj) = new_build_obj {
202202
*obj_path = Some(new_build_obj);

0 commit comments

Comments
 (0)