Skip to content

Commit

Permalink
refactor(core): non use unwrap
Browse files Browse the repository at this point in the history
I'd rather ignore it than panic and have the app error.
  • Loading branch information
SARDONYX-sard committed Nov 14, 2023
1 parent 90cd2a9 commit 6b26f0f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions dar2oar_core/src/fs/converter/sequential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,17 @@ pub async fn convert_dar_to_oar(

async fn get_dar_files(root: impl AsRef<Path>) -> WalkDir {
WalkDir::new(root).filter(move |entry| async move {
if entry.file_type().await.unwrap().is_dir() {
Filtering::Ignore
if let Ok(file_type) = entry.file_type().await {
match file_type.is_dir() {
true => Filtering::Ignore,
false => Filtering::Continue,
}
} else {
Filtering::Continue
// NOTE: Non-existent, non-authoritative, and I/O errors will ignore.
// Reason
// - Because if there is no entry in a higher-level function, it will cause an error.
// - In async closure, Result and ? operators cannot be used.
Filtering::Ignore
}
})
}
Expand Down

0 comments on commit 6b26f0f

Please sign in to comment.