@@ -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
@@ -64,9 +73,6 @@ pub async fn init(config: Config) -> AtomicServerResult<AppState> {
6473 tracing:: info!( "Building index finished!" ) ;
6574 }
6675
67- tracing:: info!( "Setting default agent" ) ;
68- set_default_agent ( & config, & store) ?;
69-
7076 // Initialize search constructs
7177 tracing:: info!( "Starting search service" ) ;
7278 let search_state =
0 commit comments