Skip to content

Commit ede405c

Browse files
authored
fix: open path util freezing app (#5111)
* fix open path util crashing app * use spawn blocking instead * fmt
1 parent 1dd1629 commit ede405c

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

apps/app/src/api/utils.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,24 @@ pub fn highlight_in_folder<R: Runtime>(
9393
}
9494

9595
#[tauri::command]
96-
pub fn open_path<R: Runtime>(app: tauri::AppHandle<R>, path: PathBuf) {
97-
if let Err(e) = app.opener().open_path(path.to_string_lossy(), None::<&str>)
98-
{
99-
tracing::error!("Failed to open path: {}", e);
100-
}
96+
pub async fn open_path<R: Runtime>(app: tauri::AppHandle<R>, path: PathBuf) {
97+
tauri::async_runtime::spawn_blocking(move || {
98+
if let Err(e) =
99+
app.opener().open_path(path.to_string_lossy(), None::<&str>)
100+
{
101+
tracing::error!("Failed to open path: {}", e);
102+
}
103+
})
104+
.await
105+
.ok();
101106
}
102107

103108
#[tauri::command]
104-
pub fn show_launcher_logs_folder<R: Runtime>(app: tauri::AppHandle<R>) {
109+
pub async fn show_launcher_logs_folder<R: Runtime>(app: tauri::AppHandle<R>) {
105110
let path = DirectoryInfo::launcher_logs_dir().unwrap_or_default();
106111
// failure to get folder just opens filesystem
107112
// (ie: if in debug mode only and launcher_logs never created)
108-
open_path(app, path);
113+
open_path(app, path).await;
109114
}
110115

111116
// Get opening command

0 commit comments

Comments
 (0)