Skip to content

Commit ead1b32

Browse files
committed
Run project name migration asynchronously
1 parent 30222ce commit ead1b32

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

apps/desktop/src-tauri/src/update_project_names.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@ use std::{
77
use cap_project::RecordingMeta;
88
use futures::StreamExt;
99
use tauri::AppHandle;
10+
use tauri_plugin_store::StoreExt;
1011
use tokio::{fs, sync::Mutex};
1112

1213
use crate::recordings_path;
1314

1415
const STORE_KEY: &str = "uuid_projects_migrated";
1516

1617
pub fn migrate_if_needed(app: &AppHandle) -> Result<(), String> {
17-
use tauri_plugin_store::StoreExt;
18-
1918
let store = app
2019
.store("store")
2120
.map_err(|e| format!("Failed to access store: {}", e))?;
@@ -28,14 +27,19 @@ pub fn migrate_if_needed(app: &AppHandle) -> Result<(), String> {
2827
return Ok(());
2928
}
3029

31-
if let Err(err) = futures::executor::block_on(migrate(app)) {
32-
tracing::error!("Updating project names failed: {err}");
33-
}
30+
let app_handle = app.clone();
31+
tokio::spawn(async move {
32+
if let Err(err) = migrate(&app_handle).await {
33+
tracing::error!("Updating project names failed: {err}");
34+
}
3435

35-
store.set(STORE_KEY, true);
36-
store
37-
.save()
38-
.map_err(|e| format!("Failed to save store: {}", e))?;
36+
if let Ok(store) = app_handle.store("store") {
37+
store.set(STORE_KEY, true);
38+
if let Err(e) = store.save() {
39+
tracing::error!("Failed to save store after migration: {}", e);
40+
}
41+
}
42+
});
3943

4044
Ok(())
4145
}

0 commit comments

Comments
 (0)