Skip to content

Commit 862107c

Browse files
committed
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.
1 parent 778660a commit 862107c

File tree

1 file changed

+1
-31
lines changed

1 file changed

+1
-31
lines changed

src/webxdc.rs

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,6 @@ const WEBXDC_API_VERSION: u32 = 1;
5151
pub const WEBXDC_SUFFIX: &str = "xdc";
5252
const WEBXDC_DEFAULT_ICON: &str = "__webxdc__/default-icon.png";
5353

54-
/// Defines the maximal size in bytes of an .xdc file that can be sent.
55-
///
56-
/// We introduce a limit to force developer to create small .xdc
57-
/// to save user's traffic and disk space for a better ux.
58-
///
59-
/// The 100K limit should also let .xdc pass worse-quality auto-download filters
60-
/// which are usually 160K incl. base64 overhead.
61-
///
62-
/// The limit is also an experiment to see how small we can go;
63-
/// it is planned to raise that limit as needed in subsequent versions.
64-
const WEBXDC_SENDING_LIMIT: u64 = 655360;
65-
6654
/// Raw information read from manifest.toml
6755
#[derive(Debug, Deserialize, Default)]
6856
#[non_exhaustive]
@@ -229,23 +217,13 @@ impl Context {
229217
Ok(true)
230218
}
231219

232-
/// ensure that a file is an acceptable webxdc for sending
233-
/// (sending has more strict size limits).
220+
/// Ensure that a file is an acceptable webxdc for sending.
234221
pub(crate) async fn ensure_sendable_webxdc_file(&self, path: &Path) -> Result<()> {
235222
let filename = path.to_str().unwrap_or_default();
236223
if !filename.ends_with(WEBXDC_SUFFIX) {
237224
bail!("{} is not a valid webxdc file", filename);
238225
}
239226

240-
let size = tokio::fs::metadata(path).await?.len();
241-
if size > WEBXDC_SENDING_LIMIT {
242-
bail!(
243-
"webxdc {} exceeds acceptable size of {} bytes",
244-
path.to_str().unwrap_or_default(),
245-
WEBXDC_SENDING_LIMIT
246-
);
247-
}
248-
249227
let valid = match async_zip::read::fs::ZipFileReader::new(path).await {
250228
Ok(archive) => {
251229
if find_zip_entry(archive.file(), "index.html").is_none() {
@@ -887,14 +865,6 @@ mod tests {
887865
use crate::test_utils::TestContext;
888866
use crate::{message, sql};
889867

890-
#[allow(clippy::assertions_on_constants)]
891-
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
892-
async fn test_webxdc_file_limits() -> Result<()> {
893-
assert!(WEBXDC_SENDING_LIMIT >= 32768);
894-
assert!(WEBXDC_SENDING_LIMIT < 16777216);
895-
Ok(())
896-
}
897-
898868
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
899869
async fn test_is_webxdc_file() -> Result<()> {
900870
let t = TestContext::new().await;

0 commit comments

Comments
 (0)