From 0b7918a07766d8a55ddf89b570c57d63f272b3e4 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 13 Sep 2020 14:38:36 +0200 Subject: [PATCH] Limit small message size --- app/src/main/java/eu/faircode/email/Core.java | 6 +++--- app/src/main/java/eu/faircode/email/MessageHelper.java | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index a741c00413..fd57978288 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -2845,11 +2845,11 @@ class Core { if (download && message.size != null && !message.ui_hide) { long maxSize; if (state == null || state.networkState.isUnmetered()) - maxSize = MessageHelper.DEFAULT_DOWNLOAD_SIZE; + maxSize = MessageHelper.SMALL_MESSAGE_SIZE; else { maxSize = prefs.getInt("download", MessageHelper.DEFAULT_DOWNLOAD_SIZE); - if (maxSize == 0) - maxSize = MessageHelper.DEFAULT_DOWNLOAD_SIZE; + if (maxSize == 0 || maxSize > MessageHelper.SMALL_MESSAGE_SIZE) + maxSize = MessageHelper.SMALL_MESSAGE_SIZE; } if (message.size < maxSize) { diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java index da712d1a57..67ae22d1b7 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -113,6 +113,7 @@ public class MessageHelper { private static File cacheDir = null; + static final int SMALL_MESSAGE_SIZE = 192 * 1024; // bytes static final int DEFAULT_DOWNLOAD_SIZE = 256 * 1024; // bytes static final String HEADER_CORRELATION_ID = "X-Correlation-ID";