From 7e4e03f28285c1224e49ba434f137abcf05c3f9a Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 6 Nov 2020 08:09:26 +0100 Subject: [PATCH] Limit number of fetch operations --- app/src/main/java/eu/faircode/email/EntityOperation.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/src/main/java/eu/faircode/email/EntityOperation.java b/app/src/main/java/eu/faircode/email/EntityOperation.java index 21465ca82a..ef93682cb1 100644 --- a/app/src/main/java/eu/faircode/email/EntityOperation.java +++ b/app/src/main/java/eu/faircode/email/EntityOperation.java @@ -101,6 +101,8 @@ public class EntityOperation { static final String RULE = "rule"; static final String PURGE = "purge"; + private static final int MAX_FETCH = 100; // operations + static void queue(Context context, EntityMessage message, String name, Object... values) { DB db = DB.getInstance(context); @@ -315,6 +317,12 @@ public class EntityOperation { } return; + } else if (FETCH.equals(name)) { + int count = db.operation().getOperationCount(message.folder, name); + if (count >= MAX_FETCH) { + sync(context, message.folder, false); + return; + } } else if (DELETE.equals(name)) { db.message().setMessageUiHide(message.id, true);