@@ -333,6 +333,7 @@ impl PlannerTrait for WdPostPlanner {
333
333
}
334
334
}
335
335
336
+ #[ derive( Debug ) ]
336
337
struct PostPath {
337
338
cache_dir : PathBuf ,
338
339
sealed_file : PathBuf ,
@@ -416,14 +417,15 @@ impl WdPost<'_> {
416
417
. build_paths ( & wdpost_job. input )
417
418
. context ( "build paths" )
418
419
. abort ( ) ?;
419
-
420
420
// get sealed path and cache path
421
421
let replica = wdpost_job
422
422
. input
423
423
. sectors
424
424
. iter ( )
425
425
. map ( |sector| {
426
- let p = paths. remove ( & sector. sector_id ) . context ( "get path" ) ?;
426
+ let p = paths. remove ( & sector. sector_id ) . with_context ( || {
427
+ format ! ( "get path for {}" , sector. sector_id)
428
+ } ) ?;
427
429
let replica = PoStReplicaInfo {
428
430
sector_id : sector. sector_id ,
429
431
comm_r : sector. comm_r ,
@@ -487,6 +489,7 @@ impl WdPost<'_> {
487
489
& self ,
488
490
input : & WdPoStInput ,
489
491
) -> Result < HashMap < SectorId , PostPath > > {
492
+ #[ derive( Debug ) ]
490
493
struct Resources {
491
494
cache_dir : Vec < Resource > ,
492
495
sealed_file : Vec < Resource > ,
@@ -540,6 +543,7 @@ impl WdPost<'_> {
540
543
let cache_dirs = instance
541
544
. paths ( resources. cache_dir . clone ( ) )
542
545
. with_context ( || format ! ( "get cache paths for {}" , ins) ) ?;
546
+
543
547
for ( resource, sealed_file) in
544
548
resources. sealed_file . iter ( ) . zip ( sealed_files)
545
549
{
@@ -548,9 +552,16 @@ impl WdPost<'_> {
548
552
. expect ( "sector_id must be set" )
549
553
. number
550
554
. into ( ) ;
551
- paths. entry ( sid) . and_modify ( |e| {
552
- e. sealed_file = sealed_file;
553
- } ) ;
555
+ let mut sealed_file = Some ( sealed_file) ;
556
+ paths
557
+ . entry ( sid)
558
+ . and_modify ( |e| {
559
+ e. sealed_file = sealed_file. take ( ) . unwrap ( ) ;
560
+ } )
561
+ . or_insert_with ( || PostPath {
562
+ cache_dir : PathBuf :: new ( ) ,
563
+ sealed_file : sealed_file. take ( ) . unwrap ( ) ,
564
+ } ) ;
554
565
}
555
566
for ( resource, cache_dir) in
556
567
resources. cache_dir . iter ( ) . zip ( cache_dirs)
@@ -560,9 +571,16 @@ impl WdPost<'_> {
560
571
. expect ( "sector_id must be set" )
561
572
. number
562
573
. into ( ) ;
563
- paths. entry ( sid) . and_modify ( |e| {
564
- e. cache_dir = cache_dir;
565
- } ) ;
574
+ let mut cache_dir = Some ( cache_dir) ;
575
+ paths
576
+ . entry ( sid)
577
+ . and_modify ( |e| {
578
+ e. cache_dir = cache_dir. take ( ) . unwrap ( ) ;
579
+ } )
580
+ . or_insert_with ( || PostPath {
581
+ cache_dir : cache_dir. take ( ) . unwrap ( ) ,
582
+ sealed_file : PathBuf :: new ( ) ,
583
+ } ) ;
566
584
}
567
585
}
568
586
Ok ( paths)
0 commit comments