Skip to content

Commit 71c6416

Browse files
committed
fix(wdpost): get path correctly
1 parent 19f7965 commit 71c6416

File tree

2 files changed

+28
-10
lines changed
  • damocles-worker/src

2 files changed

+28
-10
lines changed

damocles-worker/src/infra/filestore/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,12 @@ impl FileStore for DefaultFileStore {
187187
custom: None,
188188
},
189189
Resource::Update(sid) => StoreResource {
190-
path_type: crate::rpc::sealer::PathType::Sealed,
190+
path_type: crate::rpc::sealer::PathType::Update,
191191
sector_id: Some(sid),
192192
custom: None,
193193
},
194194
Resource::Cache(sid) => StoreResource {
195-
path_type: crate::rpc::sealer::PathType::Sealed,
195+
path_type: crate::rpc::sealer::PathType::Cache,
196196
sector_id: Some(sid),
197197
custom: None,
198198
},

damocles-worker/src/sealing/sealing_thread/planner/wdpost.rs

+26-8
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ impl PlannerTrait for WdPostPlanner {
333333
}
334334
}
335335

336+
#[derive(Debug)]
336337
struct PostPath {
337338
cache_dir: PathBuf,
338339
sealed_file: PathBuf,
@@ -416,14 +417,15 @@ impl WdPost<'_> {
416417
.build_paths(&wdpost_job.input)
417418
.context("build paths")
418419
.abort()?;
419-
420420
// get sealed path and cache path
421421
let replica = wdpost_job
422422
.input
423423
.sectors
424424
.iter()
425425
.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+
})?;
427429
let replica = PoStReplicaInfo {
428430
sector_id: sector.sector_id,
429431
comm_r: sector.comm_r,
@@ -487,6 +489,7 @@ impl WdPost<'_> {
487489
&self,
488490
input: &WdPoStInput,
489491
) -> Result<HashMap<SectorId, PostPath>> {
492+
#[derive(Debug)]
490493
struct Resources {
491494
cache_dir: Vec<Resource>,
492495
sealed_file: Vec<Resource>,
@@ -540,6 +543,7 @@ impl WdPost<'_> {
540543
let cache_dirs = instance
541544
.paths(resources.cache_dir.clone())
542545
.with_context(|| format!("get cache paths for {}", ins))?;
546+
543547
for (resource, sealed_file) in
544548
resources.sealed_file.iter().zip(sealed_files)
545549
{
@@ -548,9 +552,16 @@ impl WdPost<'_> {
548552
.expect("sector_id must be set")
549553
.number
550554
.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+
});
554565
}
555566
for (resource, cache_dir) in
556567
resources.cache_dir.iter().zip(cache_dirs)
@@ -560,9 +571,16 @@ impl WdPost<'_> {
560571
.expect("sector_id must be set")
561572
.number
562573
.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+
});
566584
}
567585
}
568586
Ok(paths)

0 commit comments

Comments
 (0)