@@ -45,7 +45,7 @@ use tokio::{
4545use tracing:: { debug, instrument, trace, warn} ;
4646
4747use crate :: {
48- connection:: { self , Connection as SqliteAsyncConn , Pool as SqlitePool } ,
48+ connection:: { Connection as SqliteAsyncConn , Pool as SqlitePool } ,
4949 error:: { Error , Result } ,
5050 utils:: {
5151 repeat_vars, EncryptableStore , Key , SqliteAsyncConnExt , SqliteKeyValueStoreAsyncConnExt ,
@@ -123,15 +123,12 @@ impl SqliteStateStore {
123123
124124 /// Open the SQLite-based state store with the config open config.
125125 pub async fn open_with_config ( config : SqliteStoreConfig ) -> Result < Self , OpenStoreError > {
126- let SqliteStoreConfig { path , pool_config , runtime_config , secret } = config;
126+ fs :: create_dir_all ( & config. path ) . await . map_err ( OpenStoreError :: CreateDir ) ? ;
127127
128- fs :: create_dir_all ( & path ) . await . map_err ( OpenStoreError :: CreateDir ) ?;
128+ let pool = config . build_pool_of_connections ( DATABASE_NAME ) ?;
129129
130- let config = connection:: Config :: new ( path. join ( DATABASE_NAME ) , pool_config) ;
131- let pool = config. create_pool ( ) ?;
132-
133- let this = Self :: open_with_pool ( pool, secret) . await ?;
134- this. pool . get ( ) . await ?. apply_runtime_config ( runtime_config) . await ?;
130+ let this = Self :: open_with_pool ( pool, config. secret ) . await ?;
131+ this. pool . get ( ) . await ?. apply_runtime_config ( config. runtime_config ) . await ?;
135132
136133 Ok ( this)
137134 }
@@ -2407,10 +2404,9 @@ mod migration_tests {
24072404
24082405 use super :: { init, keys, SqliteStateStore , DATABASE_NAME } ;
24092406 use crate :: {
2410- connection,
24112407 error:: { Error , Result } ,
24122408 utils:: { EncryptableStore as _, SqliteAsyncConnExt , SqliteKeyValueStoreAsyncConnExt } ,
2413- OpenStoreError , PoolConfig , Secret ,
2409+ OpenStoreError , Secret , SqliteStoreConfig ,
24142410 } ;
24152411
24162412 static TMP_DIR : Lazy < TempDir > = Lazy :: new ( || tempdir ( ) . unwrap ( ) ) ;
@@ -2423,10 +2419,11 @@ mod migration_tests {
24232419 }
24242420
24252421 async fn create_fake_db ( path : & Path , version : u8 ) -> Result < SqliteStateStore > {
2426- fs:: create_dir_all ( & path) . await . map_err ( OpenStoreError :: CreateDir ) . unwrap ( ) ;
2422+ let config = SqliteStoreConfig :: new ( path) ;
2423+
2424+ fs:: create_dir_all ( & config. path ) . await . map_err ( OpenStoreError :: CreateDir ) . unwrap ( ) ;
24272425
2428- let config = connection:: Config :: new ( path. join ( DATABASE_NAME ) , PoolConfig :: default ( ) ) ;
2429- let pool = config. create_pool ( ) . unwrap ( ) ;
2426+ let pool = config. build_pool_of_connections ( DATABASE_NAME ) . unwrap ( ) ;
24302427 let conn = pool. get ( ) . await ?;
24312428
24322429 init ( & conn) . await ?;
0 commit comments