@@ -4,14 +4,14 @@ use std::sync::Arc;
44use libsql_sys:: ffi:: Sqlite3DbHeader ;
55use libsql_sys:: wal:: Sqlite3WalManager ;
66use libsql_wal:: io:: StdIO ;
7+ use libsql_wal:: registry:: WalRegistry ;
78use libsql_wal:: replication:: injector:: Injector ;
89use libsql_wal:: segment:: { Frame , FrameHeader } ;
910use libsql_wal:: storage:: NoStorage ;
10- use libsql_wal:: registry:: WalRegistry ;
1111use tempfile:: TempDir ;
1212use tokio:: io:: AsyncReadExt ;
1313use tokio_stream:: StreamExt ;
14- use zerocopy:: { FromZeroes , FromBytes } ;
14+ use zerocopy:: { FromBytes , FromZeroes } ;
1515
1616#[ cfg( not( feature = "durable-wal" ) ) ]
1717use libsql_sys:: wal:: either:: Either as EitherWAL ;
@@ -35,8 +35,7 @@ pub async fn bottomless_migrate(
3535 meta_store : MetaStore ,
3636 base_config : BaseNamespaceConfig ,
3737 primary_config : PrimaryConfig ,
38- ) -> anyhow:: Result < ( ) >
39- {
38+ ) -> anyhow:: Result < ( ) > {
4039 let base_dbs_dir = base_config. base_path . join ( "dbs" ) ;
4140 let base_dbs_dir_tmp = base_config. base_path . join ( "_dbs" ) ;
4241 // the previous migration failed. The _dbs is still present, but the wals is not. In this case
@@ -62,15 +61,17 @@ pub async fn bottomless_migrate(
6261 tokio:: spawn ( async move {
6362 loop {
6463 match rcv. recv ( ) . await {
65- Some ( libsql_wal:: checkpointer:: CheckpointMessage :: Shutdown ) | None => {
66- break
67- }
64+ Some ( libsql_wal:: checkpointer:: CheckpointMessage :: Shutdown ) | None => break ,
6865 Some ( _) => ( ) ,
6966 }
7067 }
7168 } ) ;
7269
73- let tmp_registry = Arc :: new ( WalRegistry :: new ( tmp. path ( ) . join ( "wals" ) , NoStorage . into ( ) , sender) ?) ;
70+ let tmp_registry = Arc :: new ( WalRegistry :: new (
71+ tmp. path ( ) . join ( "wals" ) ,
72+ NoStorage . into ( ) ,
73+ sender,
74+ ) ?) ;
7475
7576 let mut configurators = NamespaceConfigurators :: default ( ) ;
7677
@@ -129,8 +130,7 @@ async fn migrate_one(
129130 tmp : & Path ,
130131 tmp_registry : Arc < WalRegistry < StdIO , NoStorage > > ,
131132 base_path : & Path ,
132- ) -> anyhow:: Result < ( ) >
133- {
133+ ) -> anyhow:: Result < ( ) > {
134134 let broadcasters = BroadcasterRegistry :: default ( ) ;
135135 // TODO: check if we already have a backup for this db from storage
136136 tracing:: info!( "started namespace migration" ) ;
@@ -150,18 +150,17 @@ async fn migrate_one(
150150 )
151151 . await ?;
152152
153- let db_dir = tmp
154- . join ( "dbs" )
155- . join ( config. namespace ( ) . as_str ( ) ) ;
153+ let db_dir = tmp. join ( "dbs" ) . join ( config. namespace ( ) . as_str ( ) ) ;
156154 tokio:: fs:: create_dir_all ( & db_dir) . await ?;
157155 let db_path = db_dir. join ( "data" ) ;
158156 let registry = tmp_registry. clone ( ) ;
159157 let namespace = config. namespace ( ) . clone ( ) ;
160158 let shared = tokio:: task:: spawn_blocking ( {
161159 let registry = registry. clone ( ) ;
162- move || registry. open ( & db_path, & namespace. into ( ) ) } )
163- . await
164- . unwrap ( ) ?;
160+ move || registry. open ( & db_path, & namespace. into ( ) )
161+ } )
162+ . await
163+ . unwrap ( ) ?;
165164
166165 let mut tx = shared. begin_read ( 0 ) . into ( ) ;
167166 shared. upgrade ( & mut tx) . unwrap ( ) ;
@@ -200,9 +199,9 @@ async fn migrate_one(
200199
201200 drop ( injector) ;
202201
203- tokio:: task:: spawn_blocking ( move || {
204- shared . seal_current ( )
205- } ) . await . unwrap ( ) ?;
202+ tokio:: task:: spawn_blocking ( move || shared . seal_current ( ) )
203+ . await
204+ . unwrap ( ) ?;
206205
207206 tracing:: info!( "sucessfull migration" ) ;
208207
0 commit comments