Replace BlobError type with anyhow

This commit is contained in:
link2xt
2022-06-11 19:09:44 +00:00
parent 29eb2cc68a
commit 5c0447ee29
3 changed files with 40 additions and 185 deletions

View File

@@ -11,7 +11,7 @@ use deltachat_derive::{FromSql, ToSql};
use serde::{Deserialize, Serialize};
use crate::aheader::EncryptPreference;
use crate::blob::{BlobError, BlobObject};
use crate::blob::BlobObject;
use crate::color::str_to_color;
use crate::config::Config;
use crate::constants::{
@@ -3022,15 +3022,8 @@ pub async fn set_chat_profile_image(
msg.param.remove(Param::Arg);
msg.text = Some(stock_str::msg_grp_img_deleted(context, ContactId::SELF).await);
} else {
let mut image_blob = match BlobObject::from_path(context, Path::new(new_image.as_ref())) {
Ok(blob) => Ok(blob),
Err(err) => match err {
BlobError::WrongBlobdir { .. } => {
BlobObject::create_and_copy(context, Path::new(new_image.as_ref())).await
}
_ => Err(err),
},
}?;
let mut image_blob =
BlobObject::new_from_path(context, Path::new(new_image.as_ref())).await?;
image_blob.recode_to_avatar_size(context).await?;
chat.param.set(Param::ProfileImage, image_blob.as_name());
msg.param.set(Param::Arg, image_blob.as_name());