From 53b40c969bcbdc90c1becf577a40fc25d6f7184a Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Mon, 21 Oct 2024 16:02:32 +0200 Subject: [PATCH] feat(media): don't clone the data when uploading an encrypted media --- crates/matrix-sdk/src/encryption/mod.rs | 2 +- crates/matrix-sdk/src/room/mod.rs | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/crates/matrix-sdk/src/encryption/mod.rs b/crates/matrix-sdk/src/encryption/mod.rs index 0466716b3e6..b59c3e96d0a 100644 --- a/crates/matrix-sdk/src/encryption/mod.rs +++ b/crates/matrix-sdk/src/encryption/mod.rs @@ -456,7 +456,7 @@ impl Client { pub(crate) async fn upload_encrypted_media_and_thumbnail( &self, content_type: &mime::Mime, - data: Vec, + data: &[u8], thumbnail: Option, send_progress: SharedObservable, ) -> Result<(MediaSource, Option, Option>)> { diff --git a/crates/matrix-sdk/src/room/mod.rs b/crates/matrix-sdk/src/room/mod.rs index 83030185fdb..1978fe78fb4 100644 --- a/crates/matrix-sdk/src/room/mod.rs +++ b/crates/matrix-sdk/src/room/mod.rs @@ -1936,12 +1936,7 @@ impl Room { #[cfg(feature = "e2e-encryption")] let (media_source, thumbnail_source, thumbnail_info) = if self.is_encrypted().await? { self.client - .upload_encrypted_media_and_thumbnail( - content_type, - data.clone(), - thumbnail, - send_progress, - ) + .upload_encrypted_media_and_thumbnail(content_type, &data, thumbnail, send_progress) .await? } else { self.client