@@ -298,7 +298,7 @@ impl HashContext {
298298 . get_or_create ( || async {
299299 let res = self . db ( ) . get ( hash) . await . map_err ( io:: Error :: other) ?;
300300 let res = match res {
301- Some ( state) => open_bao_file ( & hash , state, & self . global ) . await ,
301+ Some ( state) => open_bao_file ( state, self ) . await ,
302302 None => Err ( io:: Error :: new ( io:: ErrorKind :: NotFound , "hash not found" ) ) ,
303303 } ;
304304 Ok ( ( res?, ( ) ) )
@@ -318,7 +318,7 @@ impl HashContext {
318318 . get_or_create ( || async {
319319 let res = self . db ( ) . get ( hash) . await . map_err ( io:: Error :: other) ?;
320320 let res = match res {
321- Some ( state) => open_bao_file ( & hash , state, & self . global ) . await ,
321+ Some ( state) => open_bao_file ( state, self ) . await ,
322322 None => Ok ( BaoFileHandle :: new_partial_mem ( ) ) ,
323323 } ;
324324 Ok ( ( res?, ( ) ) )
@@ -331,12 +331,9 @@ impl HashContext {
331331 }
332332}
333333
334- async fn open_bao_file (
335- hash : & Hash ,
336- state : EntryState < Bytes > ,
337- ctx : & TaskContext ,
338- ) -> io:: Result < BaoFileHandle > {
339- let options = & ctx. options ;
334+ async fn open_bao_file ( state : EntryState < Bytes > , ctx : & HashContext ) -> io:: Result < BaoFileHandle > {
335+ let hash = & ctx. id ;
336+ let options = & ctx. global . options ;
340337 Ok ( match state {
341338 EntryState :: Complete {
342339 data_location,
@@ -368,7 +365,7 @@ async fn open_bao_file(
368365 } ;
369366 BaoFileHandle :: new_complete ( data, outboard)
370367 }
371- EntryState :: Partial { .. } => BaoFileHandle :: new_partial_file ( * hash , ctx) . await ?,
368+ EntryState :: Partial { .. } => BaoFileHandle :: new_partial_file ( ctx) . await ?,
372369 } )
373370}
374371
0 commit comments