@@ -7,7 +7,7 @@ use atomic_lib::{
7
7
atomic_url:: Routes ,
8
8
commit:: CommitResponse ,
9
9
email:: SmtpConfig ,
10
- Storelike ,
10
+ Db , Storelike ,
11
11
} ;
12
12
13
13
/// The AppState contains all the relevant Context for the server.
@@ -27,6 +27,15 @@ pub struct AppState {
27
27
pub search_state : SearchState ,
28
28
}
29
29
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
+
30
39
/// Creates the AppState (the server's context available in Handlers).
31
40
/// Initializes or opens a store on disk.
32
41
/// Creates a new agent, if necessary.
@@ -43,7 +52,7 @@ pub async fn init(config: Config) -> AtomicServerResult<AppState> {
43
52
}
44
53
45
54
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) ?;
47
56
48
57
if let Some ( host) = & config. opts . smpt_host {
49
58
store
@@ -64,9 +73,6 @@ pub async fn init(config: Config) -> AtomicServerResult<AppState> {
64
73
tracing:: info!( "Building index finished!" ) ;
65
74
}
66
75
67
- tracing:: info!( "Setting default agent" ) ;
68
- set_default_agent ( & config, & store) ?;
69
-
70
76
// Initialize search constructs
71
77
tracing:: info!( "Starting search service" ) ;
72
78
let search_state =
0 commit comments