You've already forked AstralRinth
forked from didirus/AstralRinth
fix: open path util freezing app (#5111)
* fix open path util crashing app * use spawn blocking instead * fmt
This commit is contained in:
@@ -93,19 +93,24 @@ pub fn highlight_in_folder<R: Runtime>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn open_path<R: Runtime>(app: tauri::AppHandle<R>, path: PathBuf) {
|
pub async fn open_path<R: Runtime>(app: tauri::AppHandle<R>, path: PathBuf) {
|
||||||
if let Err(e) = app.opener().open_path(path.to_string_lossy(), None::<&str>)
|
tauri::async_runtime::spawn_blocking(move || {
|
||||||
{
|
if let Err(e) =
|
||||||
tracing::error!("Failed to open path: {}", e);
|
app.opener().open_path(path.to_string_lossy(), None::<&str>)
|
||||||
}
|
{
|
||||||
|
tracing::error!("Failed to open path: {}", e);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn show_launcher_logs_folder<R: Runtime>(app: tauri::AppHandle<R>) {
|
pub async fn show_launcher_logs_folder<R: Runtime>(app: tauri::AppHandle<R>) {
|
||||||
let path = DirectoryInfo::launcher_logs_dir().unwrap_or_default();
|
let path = DirectoryInfo::launcher_logs_dir().unwrap_or_default();
|
||||||
// failure to get folder just opens filesystem
|
// failure to get folder just opens filesystem
|
||||||
// (ie: if in debug mode only and launcher_logs never created)
|
// (ie: if in debug mode only and launcher_logs never created)
|
||||||
open_path(app, path);
|
open_path(app, path).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get opening command
|
// Get opening command
|
||||||
|
|||||||
Reference in New Issue
Block a user