From 16f1b8281a34d8d6c1722eacadae1c2a424875aa Mon Sep 17 00:00:00 2001 From: Googlefan Date: Tue, 24 Sep 2024 02:51:59 +0000 Subject: [PATCH] refactor(src-tauri/src/main.rs): update directory handling for open and path commands --- src-tauri/src/main.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 40df9f3..de43907 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -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 { - 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()) }