Skip to content

Commit

Permalink
refactor(src-tauri/src/main.rs): update directory handling for open a…
Browse files Browse the repository at this point in the history
…nd path commands
  • Loading branch information
Googlefan committed Sep 24, 2024
1 parent 3b68e1b commit 16f1b82
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,21 @@ use hf_hub::api::sync::Api;

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

#[tauri::command]
fn path() -> Result<String, String> {
env::current_dir()
.map(|p| p.to_string_lossy().to_string())
env::current_exe()
.map(|p| {
p.parent()
.unwrap()
.join("models")
.to_string_lossy()
.to_string()
})
.map_err(|e| e.to_string())
}

Expand Down

0 comments on commit 16f1b82

Please sign in to comment.