@@ -7,15 +7,14 @@ use std::{
77use cap_project:: RecordingMeta ;
88use futures:: StreamExt ;
99use tauri:: AppHandle ;
10+ use tauri_plugin_store:: StoreExt ;
1011use tokio:: { fs, sync:: Mutex } ;
1112
1213use crate :: recordings_path;
1314
1415const STORE_KEY : & str = "uuid_projects_migrated" ;
1516
1617pub 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