From 588c3e8ef94f2238fc6f8cbc7ad111cd7c6140a6 Mon Sep 17 00:00:00 2001 From: Abdulla Abdurakhmanov Date: Sat, 9 Nov 2024 10:30:31 +0100 Subject: [PATCH] fix: Clippy fixes --- src/redacters/stream_redacter.rs | 107 +++++++++++++++---------------- 1 file changed, 52 insertions(+), 55 deletions(-) diff --git a/src/redacters/stream_redacter.rs b/src/redacters/stream_redacter.rs index 62e314e..6e812dc 100644 --- a/src/redacters/stream_redacter.rs +++ b/src/redacters/stream_redacter.rs @@ -64,64 +64,44 @@ impl<'a> StreamRedacter<'a> { } if stream_redact_plan.supported_redacters.is_empty() { - match &file_ref.media_type { - Some(file_ref_media) => { - // Supports with conversion - if Redacters::is_mime_table(file_ref_media) { - for redacter in redacters { - let supported_options = redacter - .redact_support(&FileSystemRef { - media_type: Some(mime::TEXT_PLAIN), - ..file_ref.clone() - }) - .await?; - if supported_options == RedactSupport::Supported { - stream_redact_plan.supported_redacters.push(redacter); - } - } - if !stream_redact_plan.supported_redacters.is_empty() { - stream_redact_plan.leave_data_table_as_text = true; + if let Some(file_ref_media) = &file_ref.media_type { + // Supports with conversion + if Redacters::is_mime_table(file_ref_media) { + for redacter in redacters { + let supported_options = redacter + .redact_support(&FileSystemRef { + media_type: Some(mime::TEXT_PLAIN), + ..file_ref.clone() + }) + .await?; + if supported_options == RedactSupport::Supported { + stream_redact_plan.supported_redacters.push(redacter); } - } else if self.file_converters.pdf_image_converter.is_some() - && Redacters::is_mime_pdf(file_ref_media) - { - for redacter in redacters { - let supported_options = redacter - .redact_support(&FileSystemRef { - media_type: Some(mime::IMAGE_PNG), - ..file_ref.clone() - }) - .await?; - if supported_options == RedactSupport::Supported { - stream_redact_plan.supported_redacters.push(redacter); - } + } + if !stream_redact_plan.supported_redacters.is_empty() { + stream_redact_plan.leave_data_table_as_text = true; + } + } else if self.file_converters.pdf_image_converter.is_some() + && Redacters::is_mime_pdf(file_ref_media) + { + for redacter in redacters { + let supported_options = redacter + .redact_support(&FileSystemRef { + media_type: Some(mime::IMAGE_PNG), + ..file_ref.clone() + }) + .await?; + if supported_options == RedactSupport::Supported { + stream_redact_plan.supported_redacters.push(redacter); } + } - if !stream_redact_plan.supported_redacters.is_empty() { - stream_redact_plan.apply_pdf_image_converter = true; - } + if !stream_redact_plan.supported_redacters.is_empty() { + stream_redact_plan.apply_pdf_image_converter = true; + } - if stream_redact_plan.supported_redacters.is_empty() - && self.file_converters.ocr.is_some() - { - for redacter in redacters { - let supported_options = redacter - .redact_support(&FileSystemRef { - media_type: Some(mime::TEXT_PLAIN), - ..file_ref.clone() - }) - .await?; - if supported_options == RedactSupport::Supported { - stream_redact_plan.supported_redacters.push(redacter); - } - } - if !stream_redact_plan.supported_redacters.is_empty() { - stream_redact_plan.apply_pdf_image_converter = true; - stream_redact_plan.apply_ocr = true; - } - } - } else if self.file_converters.ocr.is_some() - && Redacters::is_mime_image(file_ref_media) + if stream_redact_plan.supported_redacters.is_empty() + && self.file_converters.ocr.is_some() { for redacter in redacters { let supported_options = redacter @@ -135,11 +115,28 @@ impl<'a> StreamRedacter<'a> { } } if !stream_redact_plan.supported_redacters.is_empty() { + stream_redact_plan.apply_pdf_image_converter = true; stream_redact_plan.apply_ocr = true; } } + } else if self.file_converters.ocr.is_some() + && Redacters::is_mime_image(file_ref_media) + { + for redacter in redacters { + let supported_options = redacter + .redact_support(&FileSystemRef { + media_type: Some(mime::TEXT_PLAIN), + ..file_ref.clone() + }) + .await?; + if supported_options == RedactSupport::Supported { + stream_redact_plan.supported_redacters.push(redacter); + } + } + if !stream_redact_plan.supported_redacters.is_empty() { + stream_redact_plan.apply_ocr = true; + } } - None => {} } }