@@ -1779,7 +1779,7 @@ where
1779
1779
tokio:: select! {
1780
1780
msg = msgs. recv( ) => {
1781
1781
if let Some ( msg) = msg {
1782
- if let Err ( msg) = self . state. handle_readonly( & tables, msg) ? {
1782
+ if let Err ( msg) = self . state. handle_readonly( & tables, msg) . await ? {
1783
1783
msgs. push_back( msg) . expect( "just recv'd" ) ;
1784
1784
break ;
1785
1785
}
@@ -1808,7 +1808,7 @@ where
1808
1808
tokio:: select! {
1809
1809
msg = msgs. recv( ) => {
1810
1810
if let Some ( msg) = msg {
1811
- if let Err ( msg) = self . state. handle_readwrite( & mut tables, msg) ? {
1811
+ if let Err ( msg) = self . state. handle_readwrite( & mut tables, msg) . await ? {
1812
1812
msgs. push_back( msg) . expect( "just recv'd" ) ;
1813
1813
break ;
1814
1814
}
@@ -1853,7 +1853,7 @@ where
1853
1853
Ok ( status)
1854
1854
}
1855
1855
1856
- fn get (
1856
+ async fn get (
1857
1857
& mut self ,
1858
1858
tables : & impl ReadableTables ,
1859
1859
hash : Hash ,
@@ -1873,15 +1873,17 @@ where
1873
1873
data_location,
1874
1874
outboard_location,
1875
1875
} => {
1876
- let data = load_data ( tables, & self . options . path , data_location, & hash, & * self . fs ) ?;
1876
+ let data =
1877
+ load_data ( tables, & self . options . path , data_location, & hash, & * self . fs ) . await ?;
1877
1878
let outboard = load_outboard (
1878
1879
tables,
1879
1880
& self . options . path ,
1880
1881
outboard_location,
1881
1882
data. size ( ) ,
1882
1883
& hash,
1883
1884
& * self . fs ,
1884
- ) ?;
1885
+ )
1886
+ . await ?;
1885
1887
BaoFileHandle :: new_complete ( config, hash, data, outboard)
1886
1888
}
1887
1889
EntryState :: Partial { .. } => BaoFileHandle :: incomplete_file ( config, hash) ?,
@@ -2102,7 +2104,7 @@ where
2102
2104
Ok ( ( tag, data_size) )
2103
2105
}
2104
2106
2105
- fn get_or_create (
2107
+ async fn get_or_create (
2106
2108
& mut self ,
2107
2109
tables : & impl ReadableTables ,
2108
2110
hash : Hash ,
@@ -2121,15 +2123,17 @@ where
2121
2123
..
2122
2124
} => {
2123
2125
let data =
2124
- load_data ( tables, & self . options . path , data_location, & hash, & * self . fs ) ?;
2126
+ load_data ( tables, & self . options . path , data_location, & hash, & * self . fs )
2127
+ . await ?;
2125
2128
let outboard = load_outboard (
2126
2129
tables,
2127
2130
& self . options . path ,
2128
2131
outboard_location,
2129
2132
data. size ( ) ,
2130
2133
& hash,
2131
2134
& * self . fs ,
2132
- ) ?;
2135
+ )
2136
+ . await ?;
2133
2137
tracing:: debug!( "creating complete entry for {}" , hash. to_hex( ) ) ;
2134
2138
BaoFileHandle :: new_complete ( self . create_options . clone ( ) , hash, data, outboard)
2135
2139
}
@@ -2530,18 +2534,18 @@ where
2530
2534
Ok ( ( ) )
2531
2535
}
2532
2536
2533
- fn handle_readonly (
2537
+ async fn handle_readonly (
2534
2538
& mut self ,
2535
2539
tables : & impl ReadableTables ,
2536
2540
msg : ActorMessage < T :: File > ,
2537
2541
) -> ActorResult < std:: result:: Result < ( ) , ActorMessage < T :: File > > > {
2538
2542
match msg {
2539
2543
ActorMessage :: Get { hash, tx } => {
2540
- let res = self . get ( tables, hash) ;
2544
+ let res = self . get ( tables, hash) . await ;
2541
2545
tx. send ( res) . ok ( ) ;
2542
2546
}
2543
2547
ActorMessage :: GetOrCreate { hash, tx } => {
2544
- let res = self . get_or_create ( tables, hash) ;
2548
+ let res = self . get_or_create ( tables, hash) . await ;
2545
2549
tx. send ( res) . ok ( ) ;
2546
2550
}
2547
2551
ActorMessage :: EntryStatus { hash, tx } => {
@@ -2577,9 +2581,9 @@ where
2577
2581
Ok ( Ok ( ( ) ) )
2578
2582
}
2579
2583
2580
- fn handle_readwrite (
2584
+ async fn handle_readwrite (
2581
2585
& mut self ,
2582
- tables : & mut Tables ,
2586
+ tables : & mut Tables < ' _ > ,
2583
2587
msg : ActorMessage < T :: File > ,
2584
2588
) -> ActorResult < std:: result:: Result < ( ) , ActorMessage < T :: File > > > {
2585
2589
match msg {
@@ -2632,7 +2636,7 @@ where
2632
2636
}
2633
2637
msg => {
2634
2638
// try to handle it as readonly
2635
- if let Err ( msg) = self . handle_readonly ( tables, msg) ? {
2639
+ if let Err ( msg) = self . handle_readonly ( tables, msg) . await ? {
2636
2640
return Ok ( Err ( msg) ) ;
2637
2641
}
2638
2642
}
@@ -2700,7 +2704,7 @@ where
2700
2704
rx. blocking_recv ( ) . expect ( "The sender cannot be dropped" )
2701
2705
}
2702
2706
2703
- fn load_data < T > (
2707
+ async fn load_data < T > (
2704
2708
tables : & impl ReadableTables ,
2705
2709
options : & PathOptions ,
2706
2710
location : DataLocation < ( ) , u64 > ,
@@ -2722,7 +2726,7 @@ where
2722
2726
}
2723
2727
DataLocation :: Owned ( data_size) => {
2724
2728
let path = options. owned_data_path ( hash) ;
2725
- let Ok ( file) = block_for ( fs. open ( & path) ) else {
2729
+ let Ok ( file) = fs. open ( & path) . await else {
2726
2730
return Err ( io:: Error :: new (
2727
2731
io:: ErrorKind :: NotFound ,
2728
2732
format ! ( "file not found: {}" , path. display( ) ) ,
@@ -2741,7 +2745,7 @@ where
2741
2745
) ) ;
2742
2746
}
2743
2747
let path = & paths[ 0 ] ;
2744
- let Ok ( file) = block_for ( fs. open ( path) ) else {
2748
+ let Ok ( file) = fs. open ( path) . await else {
2745
2749
return Err ( io:: Error :: new (
2746
2750
io:: ErrorKind :: NotFound ,
2747
2751
format ! ( "external file not found: {}" , path. display( ) ) ,
@@ -2756,7 +2760,7 @@ where
2756
2760
} )
2757
2761
}
2758
2762
2759
- fn load_outboard < T : Persistence > (
2763
+ async fn load_outboard < T : Persistence > (
2760
2764
tables : & impl ReadableTables ,
2761
2765
options : & PathOptions ,
2762
2766
location : OutboardLocation ,
@@ -2778,7 +2782,7 @@ fn load_outboard<T: Persistence>(
2778
2782
OutboardLocation :: Owned => {
2779
2783
let outboard_size = raw_outboard_size ( size) ;
2780
2784
let path = options. owned_outboard_path ( hash) ;
2781
- let Ok ( file) = block_for ( fs. open ( & path) ) else {
2785
+ let Ok ( file) = fs. open ( & path) . await else {
2782
2786
return Err ( io:: Error :: new (
2783
2787
io:: ErrorKind :: NotFound ,
2784
2788
format ! ( "file not found: {} size={}" , path. display( ) , outboard_size) ,
0 commit comments