Skip to content

Commit

Permalink
tolerance to missing default element
Browse files Browse the repository at this point in the history
  • Loading branch information
miloszm committed Oct 13, 2024
1 parent 0fb3949 commit 42d56fb
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions piecrust/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,12 @@ fn index_merkle_from_path<P1: AsRef<Path>, P2: AsRef<Path>, P3: AsRef<Path>>(
main_path.as_ref(),
)
.unwrap_or(contract_leaf_path.join(ELEMENT_FILE));
let element_bytes = fs::read(element_path.clone())?;
let element: ContractIndexElement =
rkyv::from_bytes(&element_bytes).map_err(|err| {
if element_path.is_file() {
let element_bytes = fs::read(element_path.clone())?;
let element: ContractIndexElement = rkyv::from_bytes(
&element_bytes,
)
.map_err(|err| {
tracing::trace!(
"deserializing element file failed {}",
err
Expand All @@ -408,7 +411,8 @@ fn index_merkle_from_path<P1: AsRef<Path>, P2: AsRef<Path>, P3: AsRef<Path>>(
),
)
})?;
index.insert_contract_index(&contract_id, element)
index.insert_contract_index(&contract_id, element)
}
}
}

Expand Down

0 comments on commit 42d56fb

Please sign in to comment.