File tree Expand file tree Collapse file tree 3 files changed +9
-4
lines changed Expand file tree Collapse file tree 3 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -145,6 +145,7 @@ pub(crate) struct DbFsQueries {
145145
146146impl DbFsQueries {
147147 async fn init ( db : & Database ) -> anyhow:: Result < Self > {
148+ log:: debug!( "Initializing database filesystem queries" ) ;
148149 let db_kind = db. connection . any_kind ( ) ;
149150 Ok ( Self {
150151 was_modified : Self :: make_was_modified_query ( db, db_kind) . await ?,
Original file line number Diff line number Diff line change @@ -38,8 +38,10 @@ pub struct AppState {
3838
3939impl AppState {
4040 pub async fn init ( config : & AppConfig ) -> anyhow:: Result < Self > {
41- // Connect to the database
4241 let db = Database :: init ( config) . await ?;
42+ Self :: init_with_db ( config, db) . await
43+ }
44+ pub async fn init_with_db ( config : & AppConfig , db : Database ) -> anyhow:: Result < Self > {
4345 let all_templates = AllTemplates :: init ( config) ?;
4446 let mut sql_file_cache = FileCache :: new ( ) ;
4547 let file_system = FileSystem :: init ( & config. web_root , & db) . await ;
Original file line number Diff line number Diff line change @@ -2,7 +2,8 @@ use std::fmt::Write;
22
33use sqlpage:: {
44 app_config:: { self , AppConfig } ,
5- webserver, AppState ,
5+ webserver:: { self , Database } ,
6+ AppState ,
67} ;
78
89#[ actix_web:: main]
@@ -16,8 +17,9 @@ async fn main() {
1617
1718async fn start ( ) -> anyhow:: Result < ( ) > {
1819 let app_config = app_config:: load ( ) ?;
19- let state = AppState :: init ( & app_config) . await ?;
20- webserver:: database:: migrations:: apply ( & app_config, & state. db ) . await ?;
20+ let db = Database :: init ( & app_config) . await ?;
21+ webserver:: database:: migrations:: apply ( & app_config, & db) . await ?;
22+ let state = AppState :: init_with_db ( & app_config, db) . await ?;
2123 log:: debug!( "Starting server..." ) ;
2224 let ( r, _) = tokio:: join!(
2325 webserver:: http:: run_server( & app_config, state) ,
You can’t perform that action at this time.
0 commit comments