Skip to content

Commit 16f1b82

Browse files
author
Googlefan
committed
refactor(src-tauri/src/main.rs): update directory handling for open and path commands
1 parent 3b68e1b commit 16f1b82

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src-tauri/src/main.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,21 @@ use hf_hub::api::sync::Api;
77

88
#[tauri::command]
99
fn open() -> Result<(), String> {
10-
let dir = env::current_dir().map_err(|e| e.to_string())?;
11-
open::that(dir.join("models")).ok();
10+
let dir = env::current_exe().map_err(|e| e.to_string())?;
11+
open::that(dir.parent().unwrap().join("models")).ok();
1212
Ok(())
1313
}
1414

1515
#[tauri::command]
1616
fn path() -> Result<String, String> {
17-
env::current_dir()
18-
.map(|p| p.to_string_lossy().to_string())
17+
env::current_exe()
18+
.map(|p| {
19+
p.parent()
20+
.unwrap()
21+
.join("models")
22+
.to_string_lossy()
23+
.to_string()
24+
})
1925
.map_err(|e| e.to_string())
2026
}
2127

0 commit comments

Comments
 (0)