Skip to content

Commit

Permalink
Adding unwrap safety for file_name
Browse files Browse the repository at this point in the history
  • Loading branch information
marcospb19 committed Oct 15, 2021
1 parent baf23fa commit 05f82d3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ pub fn run(command: Command, flags: &oof::Flags) -> crate::Result<()> {
&& input_extensions.len() < formats.len()
&& input_extensions.iter().zip(&formats).all(|(inp, out)| inp == out)
{
// Safety:
// We checked above that input_extensions isn't empty, so files[0] has a extension.
//
// Path::extension says: "if there is no file_name, then there is no extension".
// Using DeMorgan's law: "if there is extension, then there is file_name".
info!(
"Partial compression detected. Compressing {} into {}",
to_utf(files[0].as_path().file_name().unwrap()),
Expand Down

0 comments on commit 05f82d3

Please sign in to comment.