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:
Hocuri
2025-01-22 17:25:57 +01:00
committed by link2xt
parent 744cab1553
commit 3959305b4a
10 changed files with 43 additions and 55 deletions

View File

@@ -13,7 +13,7 @@ use crate::context::Context;
use crate::net::proxy::ProxyConfig;
use crate::net::session::SessionStream;
use crate::net::tls::wrap_rustls;
use crate::tools::{create_id, time};
use crate::tools::time;
/// HTTP(S) GET response.
#[derive(Debug, Clone, PartialEq, Eq)]
@@ -119,12 +119,8 @@ fn http_url_cache_timestamps(url: &str, mimetype: Option<&str>) -> (i64, i64) {
/// Places the binary into HTTP cache.
async fn http_cache_put(context: &Context, url: &str, response: &Response) -> Result<()> {
let blob = BlobObject::create(
context,
&format!("http_cache_{}", create_id()),
response.blob.as_slice(),
)
.await?;
let blob =
BlobObject::create_and_deduplicate_from_bytes(context, response.blob.as_slice(), "")?;
let (expires, stale) = http_url_cache_timestamps(url, response.mimetype.as_deref());
context