mirror of
https://github.com/chatmail/core.git
synced 2026-04-26 01:46:34 +03:00
feat: Deduplicate in more places (#6464)
Deduplicate: - In the REPL - In `store_from_base64()`, which writes avatars received in headers - In a few tests - The saved messages, broadcast, device, archive icons - The autocrypt setup message 1-2 more PRs, and we can get rid of `BlobObject::create`, `sanitise_name()`, and some others
This commit is contained in:
@@ -2461,7 +2461,8 @@ pub(crate) async fn update_saved_messages_icon(context: &Context) -> Result<()>
|
||||
ChatIdBlocked::lookup_by_contact(context, ContactId::SELF).await?
|
||||
{
|
||||
let icon = include_bytes!("../assets/icon-saved-messages.png");
|
||||
let blob = BlobObject::create(context, "icon-saved-messages.png", icon).await?;
|
||||
let blob =
|
||||
BlobObject::create_and_deduplicate_from_bytes(context, icon, "saved-messages.png")?;
|
||||
let icon = blob.as_name().to_string();
|
||||
|
||||
let mut chat = Chat::load_from_db(context, chat_id).await?;
|
||||
@@ -2476,7 +2477,7 @@ pub(crate) async fn update_device_icon(context: &Context) -> Result<()> {
|
||||
ChatIdBlocked::lookup_by_contact(context, ContactId::DEVICE).await?
|
||||
{
|
||||
let icon = include_bytes!("../assets/icon-device.png");
|
||||
let blob = BlobObject::create(context, "icon-device.png", icon).await?;
|
||||
let blob = BlobObject::create_and_deduplicate_from_bytes(context, icon, "device.png")?;
|
||||
let icon = blob.as_name().to_string();
|
||||
|
||||
let mut chat = Chat::load_from_db(context, chat_id).await?;
|
||||
@@ -2496,7 +2497,7 @@ pub(crate) async fn get_broadcast_icon(context: &Context) -> Result<String> {
|
||||
}
|
||||
|
||||
let icon = include_bytes!("../assets/icon-broadcast.png");
|
||||
let blob = BlobObject::create(context, "icon-broadcast.png", icon).await?;
|
||||
let blob = BlobObject::create_and_deduplicate_from_bytes(context, icon, "broadcast.png")?;
|
||||
let icon = blob.as_name().to_string();
|
||||
context
|
||||
.sql
|
||||
@@ -2511,7 +2512,7 @@ pub(crate) async fn get_archive_icon(context: &Context) -> Result<String> {
|
||||
}
|
||||
|
||||
let icon = include_bytes!("../assets/icon-archive.png");
|
||||
let blob = BlobObject::create(context, "icon-archive.png", icon).await?;
|
||||
let blob = BlobObject::create_and_deduplicate_from_bytes(context, icon, "archive.png")?;
|
||||
let icon = blob.as_name().to_string();
|
||||
context
|
||||
.sql
|
||||
|
||||
Reference in New Issue
Block a user