@@ -1031,7 +1031,7 @@ impl Wal for WalFile {
10311031 self . with_shared ( |shared| {
10321032 let nbackfills = shared. nbackfills . load ( Ordering :: Acquire ) ;
10331033 turso_assert ! (
1034- frame_watermark. is_none ( ) || frame_watermark . unwrap ( ) >= nbackfills,
1034+ frame_watermark. map_or ( true , |fw| fw >= nbackfills) ,
10351035 "frame_watermark must be >= than current WAL backfill amount: frame_watermark={:?}, nBackfill={}" , frame_watermark, nbackfills
10361036 ) ;
10371037 } ) ;
@@ -1126,7 +1126,11 @@ impl Wal for WalFile {
11261126 // This means that readers trying to acquire the lock will block even if the lock is unlocked
11271127 // when there are writers waiting to acquire the lock.
11281128 // Because of this, attempts to recursively acquire a read lock within a single thread may result in a deadlock."
1129- shared. file . as_ref ( ) . unwrap ( ) . clone ( )
1129+ shared
1130+ . file
1131+ . as_ref ( )
1132+ . expect ( "WAL file must be initialized" )
1133+ . clone ( )
11301134 } ) ;
11311135 begin_read_wal_frame (
11321136 file. as_ref ( ) ,
@@ -1194,7 +1198,11 @@ impl Wal for WalFile {
11941198 } ) ;
11951199 let file = self . with_shared ( |shared| {
11961200 assert ! ( shared. enabled. load( Ordering :: SeqCst ) , "WAL must be enabled" ) ;
1197- shared. file . as_ref ( ) . unwrap ( ) . clone ( )
1201+ shared
1202+ . file
1203+ . as_ref ( )
1204+ . expect ( "WAL file must be initialized" )
1205+ . clone ( )
11981206 } ) ;
11991207 let c = begin_read_wal_frame_raw ( & self . buffer_pool , file. as_ref ( ) , offset, complete) ?;
12001208 Ok ( c)
@@ -1260,7 +1268,11 @@ impl Wal for WalFile {
12601268 } ) ;
12611269 let file = self . with_shared ( |shared| {
12621270 assert ! ( shared. enabled. load( Ordering :: SeqCst ) , "WAL must be enabled" ) ;
1263- shared. file . as_ref ( ) . unwrap ( ) . clone ( )
1271+ shared
1272+ . file
1273+ . as_ref ( )
1274+ . expect ( "WAL file must be initialized" )
1275+ . clone ( )
12641276 } ) ;
12651277 let c = begin_read_wal_frame (
12661278 file. as_ref ( ) ,
@@ -1285,7 +1297,11 @@ impl Wal for WalFile {
12851297 let ( header, file) = self . with_shared ( |shared| {
12861298 let header = shared. wal_header . clone ( ) ;
12871299 assert ! ( shared. enabled. load( Ordering :: SeqCst ) , "WAL must be enabled" ) ;
1288- let file = shared. file . as_ref ( ) . unwrap ( ) . clone ( ) ;
1300+ let file = shared
1301+ . file
1302+ . as_ref ( )
1303+ . expect ( "WAL file must be initialized" )
1304+ . clone ( ) ;
12891305 ( header, file)
12901306 } ) ;
12911307 let header = header. lock ( ) ;
@@ -1340,7 +1356,11 @@ impl Wal for WalFile {
13401356 } ) ;
13411357 let file = self . with_shared ( |shared| {
13421358 assert ! ( shared. enabled. load( Ordering :: SeqCst ) , "WAL must be enabled" ) ;
1343- shared. file . as_ref ( ) . unwrap ( ) . clone ( )
1359+ shared
1360+ . file
1361+ . as_ref ( )
1362+ . expect ( "WAL file must be initialized" )
1363+ . clone ( )
13441364 } ) ;
13451365 self . syncing . store ( true , Ordering :: SeqCst ) ;
13461366 let c = file. sync ( completion) ?;
@@ -1465,7 +1485,11 @@ impl Wal for WalFile {
14651485 assert ! ( shared. enabled. load( Ordering :: SeqCst ) , "WAL must be enabled" ) ;
14661486 (
14671487 * shared. wal_header . lock ( ) ,
1468- shared. file . as_ref ( ) . unwrap ( ) . clone ( ) ,
1488+ shared
1489+ . file
1490+ . as_ref ( )
1491+ . expect ( "WAL file must be initialized" )
1492+ . clone ( ) ,
14691493 )
14701494 } ) ;
14711495 let c = sqlite3_ondisk:: begin_write_wal_header ( file. as_ref ( ) , & header) ?;
@@ -1475,7 +1499,11 @@ impl Wal for WalFile {
14751499 fn prepare_wal_finish ( & mut self ) -> Result < Completion > {
14761500 let file = self . with_shared ( |shared| {
14771501 assert ! ( shared. enabled. load( Ordering :: SeqCst ) , "WAL must be enabled" ) ;
1478- shared. file . as_ref ( ) . unwrap ( ) . clone ( )
1502+ shared
1503+ . file
1504+ . as_ref ( )
1505+ . expect ( "WAL file must be initialized" )
1506+ . clone ( )
14791507 } ) ;
14801508 let shared = self . shared . clone ( ) ;
14811509 let c = file. sync ( Completion :: new_sync ( move |_| {
@@ -1598,7 +1626,11 @@ impl Wal for WalFile {
15981626
15991627 let file = self . with_shared ( |shared| {
16001628 assert ! ( shared. enabled. load( Ordering :: SeqCst ) , "WAL must be enabled" ) ;
1601- shared. file . as_ref ( ) . unwrap ( ) . clone ( )
1629+ shared
1630+ . file
1631+ . as_ref ( )
1632+ . expect ( "WAL file must be initialized" )
1633+ . clone ( )
16021634 } ) ;
16031635 let c = file. pwritev ( start_off, iovecs, c) ?;
16041636 Ok ( c)
@@ -2035,7 +2067,9 @@ impl WalFile {
20352067 else {
20362068 panic ! ( "unxpected state" ) ;
20372069 } ;
2038- checkpoint_result. take ( ) . unwrap ( )
2070+ checkpoint_result
2071+ . take ( )
2072+ . expect ( "checkpoint result must be present in Truncate state" )
20392073 } ;
20402074 // increment wal epoch to ensure no stale pages are used for backfilling
20412075 self . with_shared ( |shared| shared. epoch . fetch_add ( 1 , Ordering :: Release ) ) ;
@@ -2178,7 +2212,11 @@ impl WalFile {
21782212 let file = self . with_shared ( |shared| {
21792213 assert ! ( shared. enabled. load( Ordering :: SeqCst ) , "WAL must be enabled" ) ;
21802214 shared. initialized . store ( false , Ordering :: Release ) ;
2181- shared. file . as_ref ( ) . unwrap ( ) . clone ( )
2215+ shared
2216+ . file
2217+ . as_ref ( )
2218+ . expect ( "WAL file must be initialized" )
2219+ . clone ( )
21822220 } ) ;
21832221
21842222 let CheckpointState :: Truncate {
@@ -2288,7 +2326,11 @@ impl WalFile {
22882326 // schedule read of the page payload
22892327 let file = self . with_shared ( |shared| {
22902328 assert ! ( shared. enabled. load( Ordering :: SeqCst ) , "WAL must be enabled" ) ;
2291- shared. file . as_ref ( ) . unwrap ( ) . clone ( )
2329+ shared
2330+ . file
2331+ . as_ref ( )
2332+ . expect ( "WAL file must be initialized" )
2333+ . clone ( )
22922334 } ) ;
22932335 let c = begin_read_wal_frame (
22942336 file. as_ref ( ) ,
0 commit comments