From 862107c708ebd1098ff889667c888a024ad7cdf7 Mon Sep 17 00:00:00 2001 From: link2xt Date: Thu, 15 Feb 2024 17:41:19 +0000 Subject: [PATCH] feat: remove webxdc sending limit The limit is better enforced by webxdc distributors, e.g. xdc store bots or actually email providers to allow for experimentation with large frameworks or porting existing apps and testing them before reducing their size. Besides that, the comment on WEBXDC_SENDING_LIMIT was outdated, it was not updated when the limit was increased to 640 kB. --- src/webxdc.rs | 32 +------------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/src/webxdc.rs b/src/webxdc.rs index 2e50756a2..74c3fd9a0 100644 --- a/src/webxdc.rs +++ b/src/webxdc.rs @@ -51,18 +51,6 @@ const WEBXDC_API_VERSION: u32 = 1; pub const WEBXDC_SUFFIX: &str = "xdc"; const WEBXDC_DEFAULT_ICON: &str = "__webxdc__/default-icon.png"; -/// Defines the maximal size in bytes of an .xdc file that can be sent. -/// -/// We introduce a limit to force developer to create small .xdc -/// to save user's traffic and disk space for a better ux. -/// -/// The 100K limit should also let .xdc pass worse-quality auto-download filters -/// which are usually 160K incl. base64 overhead. -/// -/// The limit is also an experiment to see how small we can go; -/// it is planned to raise that limit as needed in subsequent versions. -const WEBXDC_SENDING_LIMIT: u64 = 655360; - /// Raw information read from manifest.toml #[derive(Debug, Deserialize, Default)] #[non_exhaustive] @@ -229,23 +217,13 @@ impl Context { Ok(true) } - /// ensure that a file is an acceptable webxdc for sending - /// (sending has more strict size limits). + /// Ensure that a file is an acceptable webxdc for sending. pub(crate) async fn ensure_sendable_webxdc_file(&self, path: &Path) -> Result<()> { let filename = path.to_str().unwrap_or_default(); if !filename.ends_with(WEBXDC_SUFFIX) { bail!("{} is not a valid webxdc file", filename); } - let size = tokio::fs::metadata(path).await?.len(); - if size > WEBXDC_SENDING_LIMIT { - bail!( - "webxdc {} exceeds acceptable size of {} bytes", - path.to_str().unwrap_or_default(), - WEBXDC_SENDING_LIMIT - ); - } - let valid = match async_zip::read::fs::ZipFileReader::new(path).await { Ok(archive) => { if find_zip_entry(archive.file(), "index.html").is_none() { @@ -887,14 +865,6 @@ mod tests { use crate::test_utils::TestContext; use crate::{message, sql}; - #[allow(clippy::assertions_on_constants)] - #[tokio::test(flavor = "multi_thread", worker_threads = 2)] - async fn test_webxdc_file_limits() -> Result<()> { - assert!(WEBXDC_SENDING_LIMIT >= 32768); - assert!(WEBXDC_SENDING_LIMIT < 16777216); - Ok(()) - } - #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_is_webxdc_file() -> Result<()> { let t = TestContext::new().await;