@@ -1778,7 +1778,7 @@ where
17781778 tokio:: select! {
17791779 msg = msgs. recv( ) => {
17801780 if let Some ( msg) = msg {
1781- if let Err ( msg) = self . state. handle_readonly( & tables, msg) ? {
1781+ if let Err ( msg) = self . state. handle_readonly( & tables, msg) . await ? {
17821782 msgs. push_back( msg) . expect( "just recv'd" ) ;
17831783 break ;
17841784 }
@@ -1807,7 +1807,7 @@ where
18071807 tokio:: select! {
18081808 msg = msgs. recv( ) => {
18091809 if let Some ( msg) = msg {
1810- if let Err ( msg) = self . state. handle_readwrite( & mut tables, msg) ? {
1810+ if let Err ( msg) = self . state. handle_readwrite( & mut tables, msg) . await ? {
18111811 msgs. push_back( msg) . expect( "just recv'd" ) ;
18121812 break ;
18131813 }
@@ -1852,7 +1852,7 @@ where
18521852 Ok ( status)
18531853 }
18541854
1855- fn get (
1855+ async fn get (
18561856 & mut self ,
18571857 tables : & impl ReadableTables ,
18581858 hash : Hash ,
@@ -1872,15 +1872,17 @@ where
18721872 data_location,
18731873 outboard_location,
18741874 } => {
1875- let data = load_data ( tables, & self . options . path , data_location, & hash, & * self . fs ) ?;
1875+ let data =
1876+ load_data ( tables, & self . options . path , data_location, & hash, & * self . fs ) . await ?;
18761877 let outboard = load_outboard (
18771878 tables,
18781879 & self . options . path ,
18791880 outboard_location,
18801881 data. size ( ) ,
18811882 & hash,
18821883 & * self . fs ,
1883- ) ?;
1884+ )
1885+ . await ?;
18841886 BaoFileHandle :: new_complete ( config, hash, data, outboard)
18851887 }
18861888 EntryState :: Partial { .. } => BaoFileHandle :: incomplete_file ( config, hash) ?,
@@ -2101,7 +2103,7 @@ where
21012103 Ok ( ( tag, data_size) )
21022104 }
21032105
2104- fn get_or_create (
2106+ async fn get_or_create (
21052107 & mut self ,
21062108 tables : & impl ReadableTables ,
21072109 hash : Hash ,
@@ -2120,15 +2122,17 @@ where
21202122 ..
21212123 } => {
21222124 let data =
2123- load_data ( tables, & self . options . path , data_location, & hash, & * self . fs ) ?;
2125+ load_data ( tables, & self . options . path , data_location, & hash, & * self . fs )
2126+ . await ?;
21242127 let outboard = load_outboard (
21252128 tables,
21262129 & self . options . path ,
21272130 outboard_location,
21282131 data. size ( ) ,
21292132 & hash,
21302133 & * self . fs ,
2131- ) ?;
2134+ )
2135+ . await ?;
21322136 tracing:: debug!( "creating complete entry for {}" , hash. to_hex( ) ) ;
21332137 BaoFileHandle :: new_complete ( self . create_options . clone ( ) , hash, data, outboard)
21342138 }
@@ -2529,18 +2533,18 @@ where
25292533 Ok ( ( ) )
25302534 }
25312535
2532- fn handle_readonly (
2536+ async fn handle_readonly (
25332537 & mut self ,
25342538 tables : & impl ReadableTables ,
25352539 msg : ActorMessage < T :: File > ,
25362540 ) -> ActorResult < std:: result:: Result < ( ) , ActorMessage < T :: File > > > {
25372541 match msg {
25382542 ActorMessage :: Get { hash, tx } => {
2539- let res = self . get ( tables, hash) ;
2543+ let res = self . get ( tables, hash) . await ;
25402544 tx. send ( res) . ok ( ) ;
25412545 }
25422546 ActorMessage :: GetOrCreate { hash, tx } => {
2543- let res = self . get_or_create ( tables, hash) ;
2547+ let res = self . get_or_create ( tables, hash) . await ;
25442548 tx. send ( res) . ok ( ) ;
25452549 }
25462550 ActorMessage :: EntryStatus { hash, tx } => {
@@ -2576,9 +2580,9 @@ where
25762580 Ok ( Ok ( ( ) ) )
25772581 }
25782582
2579- fn handle_readwrite (
2583+ async fn handle_readwrite (
25802584 & mut self ,
2581- tables : & mut Tables ,
2585+ tables : & mut Tables < ' _ > ,
25822586 msg : ActorMessage < T :: File > ,
25832587 ) -> ActorResult < std:: result:: Result < ( ) , ActorMessage < T :: File > > > {
25842588 match msg {
@@ -2631,7 +2635,7 @@ where
26312635 }
26322636 msg => {
26332637 // try to handle it as readonly
2634- if let Err ( msg) = self . handle_readonly ( tables, msg) ? {
2638+ if let Err ( msg) = self . handle_readonly ( tables, msg) . await ? {
26352639 return Ok ( Err ( msg) ) ;
26362640 }
26372641 }
@@ -2699,7 +2703,7 @@ where
26992703 rx. blocking_recv ( ) . expect ( "The sender cannot be dropped" )
27002704}
27012705
2702- fn load_data < T > (
2706+ async fn load_data < T > (
27032707 tables : & impl ReadableTables ,
27042708 options : & PathOptions ,
27052709 location : DataLocation < ( ) , u64 > ,
@@ -2721,7 +2725,7 @@ where
27212725 }
27222726 DataLocation :: Owned ( data_size) => {
27232727 let path = options. owned_data_path ( hash) ;
2724- let Ok ( file) = block_for ( fs. open ( & path) ) else {
2728+ let Ok ( file) = fs. open ( & path) . await else {
27252729 return Err ( io:: Error :: new (
27262730 io:: ErrorKind :: NotFound ,
27272731 format ! ( "file not found: {}" , path. display( ) ) ,
@@ -2740,7 +2744,7 @@ where
27402744 ) ) ;
27412745 }
27422746 let path = & paths[ 0 ] ;
2743- let Ok ( file) = block_for ( fs. open ( path) ) else {
2747+ let Ok ( file) = fs. open ( path) . await else {
27442748 return Err ( io:: Error :: new (
27452749 io:: ErrorKind :: NotFound ,
27462750 format ! ( "external file not found: {}" , path. display( ) ) ,
@@ -2755,7 +2759,7 @@ where
27552759 } )
27562760}
27572761
2758- fn load_outboard < T : Persistence > (
2762+ async fn load_outboard < T : Persistence > (
27592763 tables : & impl ReadableTables ,
27602764 options : & PathOptions ,
27612765 location : OutboardLocation ,
@@ -2777,7 +2781,7 @@ fn load_outboard<T: Persistence>(
27772781 OutboardLocation :: Owned => {
27782782 let outboard_size = raw_outboard_size ( size) ;
27792783 let path = options. owned_outboard_path ( hash) ;
2780- let Ok ( file) = block_for ( fs. open ( & path) ) else {
2784+ let Ok ( file) = fs. open ( & path) . await else {
27812785 return Err ( io:: Error :: new (
27822786 io:: ErrorKind :: NotFound ,
27832787 format ! ( "file not found: {} size={}" , path. display( ) , outboard_size) ,
0 commit comments