Skip to content

Commit

Permalink
feat(errors): produce a nice error message if files don't exist (#929)
Browse files Browse the repository at this point in the history
  • Loading branch information
laser authored Oct 28, 2019
1 parent 5a2b2de commit 05a7d38
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions filecoin-proofs/src/api/seal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,25 @@ pub fn seal_pre_commit<R: AsRef<Path>, T: AsRef<Path>, S: AsRef<Path>>(
ticket: Ticket,
piece_infos: &[PieceInfo],
) -> error::Result<SealPreCommitOutput> {
info!("seal_pre_commit:start");
info!("seal_pre_commit: start");
let sector_bytes = usize::from(PaddedBytesAmount::from(porep_config));

if let Err(err) = std::fs::metadata(&in_path) {
return Err(format_err!(
"could not read in_path={:?} (err = {:?})",
in_path.as_ref(),
err
));
}

if let Err(ref err) = std::fs::metadata(&out_path) {
return Err(format_err!(
"could not read out_path={:?} (err = {:?})",
in_path.as_ref(),
err
));
}

// Copy unsealed data to output location, where it will be sealed in place.
fs::copy(&in_path, &out_path)?;
let f_data = OpenOptions::new().read(true).write(true).open(&out_path)?;
Expand Down Expand Up @@ -95,7 +111,7 @@ pub fn seal_pre_commit<R: AsRef<Path>, T: AsRef<Path>, S: AsRef<Path>>(

let comm_r = commitment_from_fr::<Bls12>(tau.comm_r.into());

info!("seal_pre_commit:end");
info!("seal_pre_commit: end");

Ok(SealPreCommitOutput {
comm_r,
Expand Down

0 comments on commit 05a7d38

Please sign in to comment.