mirror of
https://github.com/chatmail/core.git
synced 2026-04-02 05:22:14 +03:00
make clippy happy
This commit is contained in:
10
src/blob.rs
10
src/blob.rs
@@ -15,6 +15,7 @@ use crate::config::Config;
|
||||
use crate::constants::*;
|
||||
use crate::context::Context;
|
||||
use crate::events::Event;
|
||||
use crate::message;
|
||||
|
||||
/// Represents a file in the blob directory.
|
||||
///
|
||||
@@ -382,6 +383,15 @@ impl<'a> BlobObject<'a> {
|
||||
|
||||
pub async fn recode_to_image_size(&self, context: &Context) -> Result<(), BlobError> {
|
||||
let blob_abs = self.to_abs_path();
|
||||
match message::guess_msgtype_from_suffix(Path::new(&blob_abs)) {
|
||||
None => return Ok(()),
|
||||
Some(imgtype) => {
|
||||
if imgtype.1 != "image/jpeg" {
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let img = image::open(&blob_abs).map_err(|err| BlobError::RecodeFailure {
|
||||
blobdir: context.get_blobdir().to_path_buf(),
|
||||
blobname: blob_abs.to_str().unwrap_or_default().to_string(),
|
||||
|
||||
@@ -1333,10 +1333,8 @@ async fn prepare_msg_blob(context: &Context, msg: &mut Message) -> Result<(), Er
|
||||
format_err!("Attachment missing for message of type #{}", msg.viewtype)
|
||||
})?;
|
||||
|
||||
if msg.viewtype == Viewtype::Image {
|
||||
if blob.recode_to_image_size(context).await.is_err() {
|
||||
warn!(context, "Cannot recode image, using original data");
|
||||
}
|
||||
if msg.viewtype == Viewtype::Image && blob.recode_to_image_size(context).await.is_err() {
|
||||
warn!(context, "Cannot recode image, using original data");
|
||||
}
|
||||
msg.param.set(Param::File, blob.as_name());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user