Skip to content

Commit

Permalink
Don't crash when checking for broken files
Browse files Browse the repository at this point in the history
  • Loading branch information
qarmin committed May 7, 2022
1 parent dd203b6 commit fe08aa1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ env:

jobs:
quality:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2

Expand Down
27 changes: 21 additions & 6 deletions czkawka_core/src/broken_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,12 +468,27 @@ impl BrokenFiles {
Err(_inspected) => Some(None), // TODO maybe throw error or something
},
TypeOfFile::Audio => match fs::File::open(&file_entry.path) {
Ok(file) => match audio_checker::parse_audio_file(file) {
Ok(_) => Some(None),
Err(e) => {
file_entry.error_string = e.to_string();
Some(Some(file_entry))
}
Ok(file) =>
{
let file_entry_clone = file_entry.clone();

let result = panic::catch_unwind(|| {
match audio_checker::parse_audio_file(file) {
Ok(_) => Some(None),
Err(e) => {
file_entry.error_string = e.to_string();
Some(Some(file_entry))
}
}
});

if let Ok(audio_result) = result {
audio_result
} else {
println!("External parsing audio library crashed when opening \"{:?}\" audio file, please report bug here - https://github.com/qarmin/audio_checker/issues", file_entry_clone.path);
Some(Some(file_entry_clone))
}

},
Err(_inspected) => Some(None), // TODO maybe throw error or something
},
Expand Down

0 comments on commit fe08aa1

Please sign in to comment.