From f0b3ec20a8b4442bda2be5696e9e00ea13a79478 Mon Sep 17 00:00:00 2001 From: xintaofei Date: Wed, 22 Apr 2026 10:53:17 +0800 Subject: [PATCH] fix(folders): add open_folder Tauri command for path-based opens --- src-tauri/src/commands/folders.rs | 15 +++++++++++++++ src-tauri/src/lib.rs | 1 + 2 files changed, 16 insertions(+) diff --git a/src-tauri/src/commands/folders.rs b/src-tauri/src/commands/folders.rs index a0d4e3c..40dd2f3 100644 --- a/src-tauri/src/commands/folders.rs +++ b/src-tauri/src/commands/folders.rs @@ -544,6 +544,21 @@ pub async fn list_all_folder_details( .map_err(AppCommandError::from) } +#[cfg(feature = "tauri-runtime")] +#[cfg_attr(feature = "tauri-runtime", tauri::command)] +pub async fn open_folder( + db: tauri::State<'_, AppDatabase>, + path: String, +) -> Result { + let entry = folder_service::add_folder(&db.conn, &path) + .await + .map_err(AppCommandError::from)?; + folder_service::get_folder_by_id(&db.conn, entry.id) + .await + .map_err(AppCommandError::from)? + .ok_or_else(|| AppCommandError::not_found("Folder not found after add")) +} + #[cfg(feature = "tauri-runtime")] #[cfg_attr(feature = "tauri-runtime", tauri::command)] pub async fn open_folder_by_id( diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 45117f7..a2e7204 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -220,6 +220,7 @@ mod tauri_app { folders::get_folder, folders::list_open_folder_details, folders::list_all_folder_details, + folders::open_folder, folders::open_folder_by_id, folders::remove_folder_from_workspace, folders::add_folder_to_history,