@@ -1775,7 +1775,7 @@ where
17751775 tokio:: select! {
17761776 msg = msgs. recv( ) => {
17771777 if let Some ( msg) = msg {
1778- if let Err ( msg) = self . state. handle_readonly( & tables, msg) ? {
1778+ if let Err ( msg) = self . state. handle_readonly( & tables, msg) . await ? {
17791779 msgs. push_back( msg) . expect( "just recv'd" ) ;
17801780 break ;
17811781 }
@@ -1804,7 +1804,7 @@ where
18041804 tokio:: select! {
18051805 msg = msgs. recv( ) => {
18061806 if let Some ( msg) = msg {
1807- if let Err ( msg) = self . state. handle_readwrite( & mut tables, msg) ? {
1807+ if let Err ( msg) = self . state. handle_readwrite( & mut tables, msg) . await ? {
18081808 msgs. push_back( msg) . expect( "just recv'd" ) ;
18091809 break ;
18101810 }
@@ -1849,7 +1849,7 @@ where
18491849 Ok ( status)
18501850 }
18511851
1852- fn get (
1852+ async fn get (
18531853 & mut self ,
18541854 tables : & impl ReadableTables ,
18551855 hash : Hash ,
@@ -1869,15 +1869,17 @@ where
18691869 data_location,
18701870 outboard_location,
18711871 } => {
1872- let data = load_data ( tables, & self . options . path , data_location, & hash, & * self . fs ) ?;
1872+ let data =
1873+ load_data ( tables, & self . options . path , data_location, & hash, & * self . fs ) . await ?;
18731874 let outboard = load_outboard (
18741875 tables,
18751876 & self . options . path ,
18761877 outboard_location,
18771878 data. size ( ) ,
18781879 & hash,
18791880 & * self . fs ,
1880- ) ?;
1881+ )
1882+ . await ?;
18811883 BaoFileHandle :: new_complete ( config, hash, data, outboard)
18821884 }
18831885 EntryState :: Partial { .. } => BaoFileHandle :: incomplete_file ( config, hash) ?,
@@ -2098,7 +2100,7 @@ where
20982100 Ok ( ( tag, data_size) )
20992101 }
21002102
2101- fn get_or_create (
2103+ async fn get_or_create (
21022104 & mut self ,
21032105 tables : & impl ReadableTables ,
21042106 hash : Hash ,
@@ -2117,15 +2119,17 @@ where
21172119 ..
21182120 } => {
21192121 let data =
2120- load_data ( tables, & self . options . path , data_location, & hash, & * self . fs ) ?;
2122+ load_data ( tables, & self . options . path , data_location, & hash, & * self . fs )
2123+ . await ?;
21212124 let outboard = load_outboard (
21222125 tables,
21232126 & self . options . path ,
21242127 outboard_location,
21252128 data. size ( ) ,
21262129 & hash,
21272130 & * self . fs ,
2128- ) ?;
2131+ )
2132+ . await ?;
21292133 tracing:: debug!( "creating complete entry for {}" , hash. to_hex( ) ) ;
21302134 BaoFileHandle :: new_complete ( self . create_options . clone ( ) , hash, data, outboard)
21312135 }
@@ -2526,18 +2530,18 @@ where
25262530 Ok ( ( ) )
25272531 }
25282532
2529- fn handle_readonly (
2533+ async fn handle_readonly (
25302534 & mut self ,
25312535 tables : & impl ReadableTables ,
25322536 msg : ActorMessage < T :: File > ,
25332537 ) -> ActorResult < std:: result:: Result < ( ) , ActorMessage < T :: File > > > {
25342538 match msg {
25352539 ActorMessage :: Get { hash, tx } => {
2536- let res = self . get ( tables, hash) ;
2540+ let res = self . get ( tables, hash) . await ;
25372541 tx. send ( res) . ok ( ) ;
25382542 }
25392543 ActorMessage :: GetOrCreate { hash, tx } => {
2540- let res = self . get_or_create ( tables, hash) ;
2544+ let res = self . get_or_create ( tables, hash) . await ;
25412545 tx. send ( res) . ok ( ) ;
25422546 }
25432547 ActorMessage :: EntryStatus { hash, tx } => {
@@ -2573,9 +2577,9 @@ where
25732577 Ok ( Ok ( ( ) ) )
25742578 }
25752579
2576- fn handle_readwrite (
2580+ async fn handle_readwrite (
25772581 & mut self ,
2578- tables : & mut Tables ,
2582+ tables : & mut Tables < ' _ > ,
25792583 msg : ActorMessage < T :: File > ,
25802584 ) -> ActorResult < std:: result:: Result < ( ) , ActorMessage < T :: File > > > {
25812585 match msg {
@@ -2628,7 +2632,7 @@ where
26282632 }
26292633 msg => {
26302634 // try to handle it as readonly
2631- if let Err ( msg) = self . handle_readonly ( tables, msg) ? {
2635+ if let Err ( msg) = self . handle_readonly ( tables, msg) . await ? {
26322636 return Ok ( Err ( msg) ) ;
26332637 }
26342638 }
@@ -2696,7 +2700,7 @@ where
26962700 rx. blocking_recv ( ) . expect ( "The sender cannot be dropped" )
26972701}
26982702
2699- fn load_data < T > (
2703+ async fn load_data < T > (
27002704 tables : & impl ReadableTables ,
27012705 options : & PathOptions ,
27022706 location : DataLocation < ( ) , u64 > ,
@@ -2718,7 +2722,7 @@ where
27182722 }
27192723 DataLocation :: Owned ( data_size) => {
27202724 let path = options. owned_data_path ( hash) ;
2721- let Ok ( file) = block_for ( fs. open ( & path) ) else {
2725+ let Ok ( file) = fs. open ( & path) . await else {
27222726 return Err ( io:: Error :: new (
27232727 io:: ErrorKind :: NotFound ,
27242728 format ! ( "file not found: {}" , path. display( ) ) ,
@@ -2737,7 +2741,7 @@ where
27372741 ) ) ;
27382742 }
27392743 let path = & paths[ 0 ] ;
2740- let Ok ( file) = block_for ( fs. open ( path) ) else {
2744+ let Ok ( file) = fs. open ( path) . await else {
27412745 return Err ( io:: Error :: new (
27422746 io:: ErrorKind :: NotFound ,
27432747 format ! ( "external file not found: {}" , path. display( ) ) ,
@@ -2752,7 +2756,7 @@ where
27522756 } )
27532757}
27542758
2755- fn load_outboard < T : Persistence > (
2759+ async fn load_outboard < T : Persistence > (
27562760 tables : & impl ReadableTables ,
27572761 options : & PathOptions ,
27582762 location : OutboardLocation ,
@@ -2774,7 +2778,7 @@ fn load_outboard<T: Persistence>(
27742778 OutboardLocation :: Owned => {
27752779 let outboard_size = raw_outboard_size ( size) ;
27762780 let path = options. owned_outboard_path ( hash) ;
2777- let Ok ( file) = block_for ( fs. open ( & path) ) else {
2781+ let Ok ( file) = fs. open ( & path) . await else {
27782782 return Err ( io:: Error :: new (
27792783 io:: ErrorKind :: NotFound ,
27802784 format ! ( "file not found: {} size={}" , path. display( ) , outboard_size) ,
0 commit comments