From 776df7505e829717a3f604686ded6da840b140a0 Mon Sep 17 00:00:00 2001 From: link2xt Date: Thu, 30 Mar 2023 13:56:15 +0000 Subject: [PATCH] Remove upper limit on the attachment size Recommended file size is used for recoding media. For the upper size, we rely on the provider to tell us back if the message cannot be delivered to some recipients. This allows to send large files, such as APKs, when using providers that don't have such strict limits. --- CHANGELOG.md | 1 + src/mimefactory.rs | 26 +++----------------------- 2 files changed, 4 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab606b355..3a7aaddad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## [Unreleased] ### Changes +- Remove upper limit on the attachment size. #4253 ### Fixes diff --git a/src/mimefactory.rs b/src/mimefactory.rs index 6d291ae23..ce4bac4c1 100644 --- a/src/mimefactory.rs +++ b/src/mimefactory.rs @@ -27,16 +27,13 @@ use crate::simplify::escape_message_footer_marks; use crate::stock_str; use crate::tools::IsNoneOrEmpty; use crate::tools::{ - create_outgoing_rfc724_mid, create_smeared_timestamp, get_filebytes, remove_subject_prefix, - time, + create_outgoing_rfc724_mid, create_smeared_timestamp, remove_subject_prefix, time, }; // attachments of 25 mb brutto should work on the majority of providers // (brutto examples: web.de=50, 1&1=40, t-online.de=32, gmail=25, posteo=50, yahoo=25, all-inkl=100). -// as an upper limit, we double the size; the core won't send messages larger than this // to get the netto sizes, we subtract 1 mb header-overhead and the base64-overhead. pub const RECOMMENDED_FILE_SIZE: u64 = 24 * 1024 * 1024 / 4 * 3; -const UPPER_LIMIT_FILE_SIZE: u64 = 49 * 1024 * 1024 / 4 * 3; #[derive(Debug, Clone)] pub enum Loaded { @@ -1211,15 +1208,8 @@ impl<'a> MimeFactory<'a> { // add attachment part if self.msg.viewtype.has_file() { - if !is_file_size_okay(context, self.msg).await? { - bail!( - "Message exceeds the recommended {} MB.", - RECOMMENDED_FILE_SIZE / 1_000_000, - ); - } else { - let (file_part, _) = build_body_file(context, self.msg, "").await?; - parts.push(file_part); - } + let (file_part, _) = build_body_file(context, self.msg, "").await?; + parts.push(file_part); } if let Some(meta_part) = meta_part { @@ -1483,16 +1473,6 @@ fn recipients_contain_addr(recipients: &[(String, String)], addr: &str) -> bool .any(|(_, cur)| cur.to_lowercase() == addr_lc) } -async fn is_file_size_okay(context: &Context, msg: &Message) -> Result { - match msg.param.get_path(Param::File, context)? { - Some(path) => { - let bytes = get_filebytes(context, &path).await?; - Ok(bytes <= UPPER_LIMIT_FILE_SIZE) - } - None => Ok(false), - } -} - fn render_rfc724_mid(rfc724_mid: &str) -> String { let rfc724_mid = rfc724_mid.trim().to_string();