@@ -543,18 +543,7 @@ async fn run_get_request(
543
543
} ;
544
544
545
545
let start = start. next ( blob. hash ) ;
546
-
547
- // `iroh_io` io needs to be done on a local spawn
548
- let ticket = ticket. clone ( ) ;
549
- let context = context. clone ( ) ;
550
- let name = blob. name . clone ( ) ;
551
- let jobs = jobs. clone ( ) ;
552
- let done = rt
553
- . local_pool ( )
554
- . spawn_pinned ( move || {
555
- Box :: pin ( async move { on_blob ( context, jobs, ticket, start, & name) . await } )
556
- } )
557
- . await ??;
546
+ let done = on_blob ( context, & rt, & jobs, & ticket, start, & blob. name ) . await ?;
558
547
559
548
next = done. next ( ) ;
560
549
} ;
@@ -568,9 +557,10 @@ async fn run_get_request(
568
557
/// This writes the blobs to the blobdir. If the blob is the database it will import it to
569
558
/// the database of the current [`Context`].
570
559
async fn on_blob (
571
- context : Context ,
572
- jobs : Arc < Mutex < JoinSet < ( ) > > > ,
573
- ticket : Ticket ,
560
+ context : & Context ,
561
+ rt : & runtime:: Handle ,
562
+ jobs : & Arc < Mutex < JoinSet < ( ) > > > ,
563
+ ticket : & Ticket ,
574
564
state : fsm:: AtBlobHeader ,
575
565
name : & str ,
576
566
) -> Result < fsm:: AtEndBlob > {
@@ -592,12 +582,23 @@ async fn on_blob(
592
582
context. get_blobdir ( ) . join ( blobname)
593
583
} ;
594
584
585
+ // `iroh_io` io needs to be done on a local spawn
595
586
let file_path = path. clone ( ) ;
596
- let mut file = iroh_io:: File :: create ( move || std:: fs:: File :: create ( & file_path) ) . await ?;
597
- // TODO: ProgressEmitter doesn't support writers :(
598
- // let mut wrapped_file = progress.wrap_async_write(&mut file);
599
- let done = state. write_all ( & mut file) . await ?;
600
- file. sync ( ) . await ?;
587
+ let done = rt
588
+ . local_pool ( )
589
+ . spawn_pinned ( move || {
590
+ let file_path = file_path. clone ( ) ;
591
+ Box :: pin ( async move {
592
+ let mut file =
593
+ iroh_io:: File :: create ( move || std:: fs:: File :: create ( & file_path) ) . await ?;
594
+ // TODO: ProgressEmitter doesn't support writers :(
595
+ // let mut wrapped_file = progress.wrap_async_write(&mut file);
596
+ let done = state. write_all ( & mut file) . await ?;
597
+ file. sync ( ) . await ?;
598
+ anyhow:: Ok ( done)
599
+ } )
600
+ } )
601
+ . await ??;
601
602
602
603
if name. starts_with ( "db/" ) {
603
604
let context = context. clone ( ) ;
0 commit comments