@@ -1775,7 +1775,7 @@ where
1775
1775
tokio:: select! {
1776
1776
msg = msgs. recv( ) => {
1777
1777
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 ? {
1779
1779
msgs. push_back( msg) . expect( "just recv'd" ) ;
1780
1780
break ;
1781
1781
}
@@ -1804,7 +1804,7 @@ where
1804
1804
tokio:: select! {
1805
1805
msg = msgs. recv( ) => {
1806
1806
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 ? {
1808
1808
msgs. push_back( msg) . expect( "just recv'd" ) ;
1809
1809
break ;
1810
1810
}
@@ -1849,7 +1849,7 @@ where
1849
1849
Ok ( status)
1850
1850
}
1851
1851
1852
- fn get (
1852
+ async fn get (
1853
1853
& mut self ,
1854
1854
tables : & impl ReadableTables ,
1855
1855
hash : Hash ,
@@ -1869,15 +1869,17 @@ where
1869
1869
data_location,
1870
1870
outboard_location,
1871
1871
} => {
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 ?;
1873
1874
let outboard = load_outboard (
1874
1875
tables,
1875
1876
& self . options . path ,
1876
1877
outboard_location,
1877
1878
data. size ( ) ,
1878
1879
& hash,
1879
1880
& * self . fs ,
1880
- ) ?;
1881
+ )
1882
+ . await ?;
1881
1883
BaoFileHandle :: new_complete ( config, hash, data, outboard)
1882
1884
}
1883
1885
EntryState :: Partial { .. } => BaoFileHandle :: incomplete_file ( config, hash) ?,
@@ -2098,7 +2100,7 @@ where
2098
2100
Ok ( ( tag, data_size) )
2099
2101
}
2100
2102
2101
- fn get_or_create (
2103
+ async fn get_or_create (
2102
2104
& mut self ,
2103
2105
tables : & impl ReadableTables ,
2104
2106
hash : Hash ,
@@ -2117,15 +2119,17 @@ where
2117
2119
..
2118
2120
} => {
2119
2121
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 ?;
2121
2124
let outboard = load_outboard (
2122
2125
tables,
2123
2126
& self . options . path ,
2124
2127
outboard_location,
2125
2128
data. size ( ) ,
2126
2129
& hash,
2127
2130
& * self . fs ,
2128
- ) ?;
2131
+ )
2132
+ . await ?;
2129
2133
tracing:: debug!( "creating complete entry for {}" , hash. to_hex( ) ) ;
2130
2134
BaoFileHandle :: new_complete ( self . create_options . clone ( ) , hash, data, outboard)
2131
2135
}
@@ -2526,18 +2530,18 @@ where
2526
2530
Ok ( ( ) )
2527
2531
}
2528
2532
2529
- fn handle_readonly (
2533
+ async fn handle_readonly (
2530
2534
& mut self ,
2531
2535
tables : & impl ReadableTables ,
2532
2536
msg : ActorMessage < T :: File > ,
2533
2537
) -> ActorResult < std:: result:: Result < ( ) , ActorMessage < T :: File > > > {
2534
2538
match msg {
2535
2539
ActorMessage :: Get { hash, tx } => {
2536
- let res = self . get ( tables, hash) ;
2540
+ let res = self . get ( tables, hash) . await ;
2537
2541
tx. send ( res) . ok ( ) ;
2538
2542
}
2539
2543
ActorMessage :: GetOrCreate { hash, tx } => {
2540
- let res = self . get_or_create ( tables, hash) ;
2544
+ let res = self . get_or_create ( tables, hash) . await ;
2541
2545
tx. send ( res) . ok ( ) ;
2542
2546
}
2543
2547
ActorMessage :: EntryStatus { hash, tx } => {
@@ -2573,9 +2577,9 @@ where
2573
2577
Ok ( Ok ( ( ) ) )
2574
2578
}
2575
2579
2576
- fn handle_readwrite (
2580
+ async fn handle_readwrite (
2577
2581
& mut self ,
2578
- tables : & mut Tables ,
2582
+ tables : & mut Tables < ' _ > ,
2579
2583
msg : ActorMessage < T :: File > ,
2580
2584
) -> ActorResult < std:: result:: Result < ( ) , ActorMessage < T :: File > > > {
2581
2585
match msg {
@@ -2628,7 +2632,7 @@ where
2628
2632
}
2629
2633
msg => {
2630
2634
// 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 ? {
2632
2636
return Ok ( Err ( msg) ) ;
2633
2637
}
2634
2638
}
@@ -2696,7 +2700,7 @@ where
2696
2700
rx. blocking_recv ( ) . expect ( "The sender cannot be dropped" )
2697
2701
}
2698
2702
2699
- fn load_data < T > (
2703
+ async fn load_data < T > (
2700
2704
tables : & impl ReadableTables ,
2701
2705
options : & PathOptions ,
2702
2706
location : DataLocation < ( ) , u64 > ,
@@ -2718,7 +2722,7 @@ where
2718
2722
}
2719
2723
DataLocation :: Owned ( data_size) => {
2720
2724
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 {
2722
2726
return Err ( io:: Error :: new (
2723
2727
io:: ErrorKind :: NotFound ,
2724
2728
format ! ( "file not found: {}" , path. display( ) ) ,
@@ -2737,7 +2741,7 @@ where
2737
2741
) ) ;
2738
2742
}
2739
2743
let path = & paths[ 0 ] ;
2740
- let Ok ( file) = block_for ( fs. open ( path) ) else {
2744
+ let Ok ( file) = fs. open ( path) . await else {
2741
2745
return Err ( io:: Error :: new (
2742
2746
io:: ErrorKind :: NotFound ,
2743
2747
format ! ( "external file not found: {}" , path. display( ) ) ,
@@ -2752,7 +2756,7 @@ where
2752
2756
} )
2753
2757
}
2754
2758
2755
- fn load_outboard < T : Persistence > (
2759
+ async fn load_outboard < T : Persistence > (
2756
2760
tables : & impl ReadableTables ,
2757
2761
options : & PathOptions ,
2758
2762
location : OutboardLocation ,
@@ -2774,7 +2778,7 @@ fn load_outboard<T: Persistence>(
2774
2778
OutboardLocation :: Owned => {
2775
2779
let outboard_size = raw_outboard_size ( size) ;
2776
2780
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 {
2778
2782
return Err ( io:: Error :: new (
2779
2783
io:: ErrorKind :: NotFound ,
2780
2784
format ! ( "file not found: {} size={}" , path. display( ) , outboard_size) ,
0 commit comments