mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-02-16 02:22:31 -05:00
Merge pull request #3118 from progval/shrink-decrypted-media
Preallocate vector storing decrypted files
This commit is contained in:
@@ -278,13 +278,17 @@ impl Media {
|
||||
|
||||
#[cfg(feature = "e2e-encryption")]
|
||||
let content = {
|
||||
let content_len = content.len();
|
||||
let mut cursor = std::io::Cursor::new(content);
|
||||
let mut reader = matrix_sdk_base::crypto::AttachmentDecryptor::new(
|
||||
&mut cursor,
|
||||
file.as_ref().clone().into(),
|
||||
)?;
|
||||
|
||||
let mut decrypted = Vec::new();
|
||||
// Encrypted size should be the same as the decrypted size,
|
||||
// rounded up to a cipher block.
|
||||
let mut decrypted = Vec::with_capacity(content_len);
|
||||
|
||||
reader.read_to_end(&mut decrypted)?;
|
||||
|
||||
decrypted
|
||||
|
||||
Reference in New Issue
Block a user