diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2023-06-18 17:54:54 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2023-07-02 20:31:33 +0200 |
commit | 9c134043fbde7738b7f9c5587c6d07c257145149 (patch) | |
tree | 1795a5db6e102e5b11b1cae5cfce8bfd3fe0fd83 | |
parent | 96056382d29d37b54f5b85b6db20a883c943f2bf (diff) |
Distinguish between error types
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r-- | src/command/verify_metadata_command.rs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/command/verify_metadata_command.rs b/src/command/verify_metadata_command.rs index 318265d..1af8cb3 100644 --- a/src/command/verify_metadata_command.rs +++ b/src/command/verify_metadata_command.rs @@ -13,15 +13,19 @@ pub struct VerifyMetadataCommand {} impl crate::command::Command for VerifyMetadataCommand { fn execute(self, workdir: &Path, config: &Configuration) -> Result<(), Error> { - let (_oks, errors): (Vec<_>, Vec<VerificationError>) = + let (_oks, errors): (Vec<_>, Vec<Error>) = walkdir::WalkDir::new(workdir.join(config.fragment_dir())) .follow_links(false) .max_open(100) .same_file_system(true) .into_iter() - .map(|rde| -> Result<_, VerificationError> { + .filter_map(|rde| match rde { + Ok(de) => de.path().is_file().then(|| de.path().to_path_buf()).map(Ok), + Err(e) => Some(Err(e)), + }) + .map(|rde| -> Result<_, Error> { let de = rde.map_err(VerificationError::from)?; - let path = de.path(); + let path = de.as_path(); if crate::command::common::get_version_from_path(path) .map_err(VerificationError::from)? @@ -51,11 +55,12 @@ impl crate::command::Command for VerifyMetadataCommand { multiple: errors, }) }) + .map_err(|ve| Error::Verification(ve)) }) .partition_result(); if !errors.is_empty() { - return Err(Error::Verification(errors)); + return Err(Error::Multiple { errors }); } Ok(()) |