Skip to content

Commit

Permalink
🧹(chore): chore
Browse files Browse the repository at this point in the history
  • Loading branch information
W-Mai committed Mar 7, 2024
1 parent d6042f8 commit 7790a56
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,9 @@ fn process() -> Result<(), Box<dyn std::error::Error>> {
None
};

log::trace!("files to be converted: {:#?}", input_files);
log::info!(
"Start converting {}",
if is_folder_input { "folder" } else { "file" }
);
let file_or_folder = if is_folder_input { "folder" } else { "file" };
log::trace!("{} to be converted: {:#?}", file_or_folder, input_files);
log::info!("Start converting {}", file_or_folder);
log::info!("");

let input_files_vec = deal_input_file_paths(input_files, &input_folder)?;
Expand All @@ -124,22 +122,26 @@ fn process() -> Result<(), Box<dyn std::error::Error>> {
.with_extension(output_format.get_file_extension());

let output_file_exists = output_file_path.exists();
if output_file_exists && !*override_output {
log::error!(
"Can't convert <{}> to <{}>, output file already exists",
file_path.to_string_lossy(),
output_file_path.to_string_lossy()
)
} else {
let should_convert = !output_file_exists || *override_output;

if should_convert {
if output_file_exists {
log::warn!(
"Override output file <{}> for converting <{}>",
output_file_path.to_string_lossy(),
file_path.to_string_lossy()
);
}
} else {
log::error!(
"Can't convert <{}> to <{}>, output file already exists",
file_path.to_string_lossy(),
output_file_path.to_string_lossy()
);
}

let deal_one_file = || -> Result<(), Box<dyn std::error::Error>> {
if should_convert {
if let Err(e) = (|| -> Result<(), Box<dyn std::error::Error>> {
let params = EncoderParams::new()
.with_stride_align(*output_stride_align)
.with_dither(*dither)
Expand All @@ -162,9 +164,7 @@ fn process() -> Result<(), Box<dyn std::error::Error>> {
}
}
Ok(())
};

if let Err(e) = deal_one_file() {
})() {
log::error!(
"Failed to convert <{}> to <{}>: {}",
file_path.to_string_lossy(),
Expand Down

0 comments on commit 7790a56

Please sign in to comment.