@@ -7,7 +7,7 @@ use atomic_lib::{
77 atomic_url:: Routes ,
88 commit:: CommitResponse ,
99 email:: SmtpConfig ,
10- Storelike ,
10+ Db , Storelike ,
1111} ;
1212
1313/// The AppState contains all the relevant Context for the server.
@@ -27,6 +27,15 @@ pub struct AppState {
2727 pub search_state : SearchState ,
2828}
2929
30+ /// Initializes the Store and sets the default agent.
31+ pub fn init_store ( config : & Config ) -> AtomicServerResult < Db > {
32+ let store = atomic_lib:: Db :: init ( & config. store_path , & config. server_url ) ?;
33+
34+ tracing:: info!( "Setting default agent" ) ;
35+ set_default_agent ( config, & store) ?;
36+ Ok ( store)
37+ }
38+
3039/// Creates the AppState (the server's context available in Handlers).
3140/// Initializes or opens a store on disk.
3241/// Creates a new agent, if necessary.
@@ -43,7 +52,7 @@ pub async fn init(config: Config) -> AtomicServerResult<AppState> {
4352 }
4453
4554 tracing:: info!( "Opening database at {:?}" , & config. store_path) ;
46- let mut store = atomic_lib :: Db :: init ( & config. store_path , & config . server_url ) ?;
55+ let mut store = init_store ( & config) ?;
4756
4857 if let Some ( host) = & config. opts . smpt_host {
4958 store
@@ -60,9 +69,6 @@ pub async fn init(config: Config) -> AtomicServerResult<AppState> {
6069 . map_err ( |e| format ! ( "Failed to populate default store. {}" , e) ) ?;
6170 }
6271
63- tracing:: info!( "Setting default agent" ) ;
64- set_default_agent ( & config, & store) ?;
65-
6672 // Initialize search constructs
6773 tracing:: info!( "Starting search service" ) ;
6874 let search_state =
0 commit comments