@@ -6,13 +6,15 @@ use tauri::{ipc::Channel, path::BaseDirectory, AppHandle, Manager, State};
66use crate :: {
77 state:: AtuinState ,
88 workspaces:: {
9- fs_ops:: WorkspaceDirInfo , manager:: WorkspaceEvent , offline_runbook:: OfflineRunbook ,
9+ fs_ops:: { WorkspaceConfig , WorkspaceDirInfo } ,
10+ manager:: WorkspaceEvent ,
11+ offline_runbook:: OfflineRunbook ,
1012 workspace:: WorkspaceError ,
1113 } ,
1214} ;
1315
1416#[ tauri:: command]
15- pub async fn copy_welcome_workspace ( app : AppHandle ) -> Result < String , String > {
17+ pub async fn copy_welcome_workspace ( app : AppHandle , id : String ) -> Result < String , String > {
1618 let welcome_path = app
1719 . path ( )
1820 . resolve ( "resources/welcome" , BaseDirectory :: Resource )
@@ -39,6 +41,17 @@ pub async fn copy_welcome_workspace(app: AppHandle) -> Result<String, String> {
3941
4042 copy_dir_all ( & welcome_path, & target_path) . map_err ( |e| e. to_string ( ) ) ?;
4143
44+ // Overwrite the ID in the copied `atuin.toml` file with the given ID
45+ let config_path = target_path. join ( "atuin.toml" ) ;
46+ let mut config = WorkspaceConfig :: from_file ( & config_path)
47+ . await
48+ . map_err ( |e| e. to_string ( ) ) ?;
49+ config. workspace . id = id;
50+ let contents = toml:: to_string ( & config) . map_err ( |e| e. to_string ( ) ) ?;
51+ tokio:: fs:: write ( config_path, contents)
52+ . await
53+ . map_err ( |e| e. to_string ( ) ) ?;
54+
4255 Ok ( target_path. to_string_lossy ( ) . to_string ( ) )
4356}
4457
0 commit comments