diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index e1207aff93..3e69d53206 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -106,6 +106,7 @@ import javax.mail.MessageRemovedException; import javax.mail.MessagingException; import javax.mail.Session; import javax.mail.Store; +import javax.mail.StoreClosedException; import javax.mail.UIDFolder; import javax.mail.internet.AddressException; import javax.mail.internet.InternetAddress; @@ -2279,7 +2280,7 @@ class Core { } if (message.total != null && message.total == 0) - reportEmptyMessage(context, account, istore); + reportEmptyMessage(context, state, account, istore); try { db.beginTransaction(); @@ -2352,7 +2353,7 @@ class Core { Long size = parts.getBodySize(); if (TextUtils.isEmpty(body) && size != null && size > 0) - reportEmptyMessage(context, account, istore); + reportEmptyMessage(context, state, account, istore); } } @@ -2686,7 +2687,7 @@ class Core { Long size = parts.getBodySize(); if (TextUtils.isEmpty(body) && size != null && size > 0) - reportEmptyMessage(context, account, istore); + reportEmptyMessage(context, state, account, istore); } } @@ -2703,7 +2704,7 @@ class Core { } } - private static void reportEmptyMessage(Context context, EntityAccount account, IMAPStore istore) { + private static void reportEmptyMessage(Context context, State state, EntityAccount account, IMAPStore istore) { try { if (istore.hasCapability("ID")) { Map id = new LinkedHashMap<>(); @@ -2721,6 +2722,14 @@ class Core { } catch (Throwable ex) { Log.w(ex); } + + // Auto disable partial fetch + if (account.partial_fetch) { + account.partial_fetch = false; + DB db = DB.getInstance(context); + db.account().setAccountPartialFetch(account.id, account.partial_fetch); + state.error(new StoreClosedException(istore)); + } } static void notifyMessages(Context context, List messages, Map> groupNotifying) { @@ -3454,7 +3463,8 @@ class Core { // BYE, Socket is closed recoverable = false; - if (ex instanceof FolderClosedException || + if (ex instanceof StoreClosedException || + ex instanceof FolderClosedException || ex instanceof FolderNotFoundException) // Lost folder connection to server recoverable = false; diff --git a/app/src/main/java/eu/faircode/email/DaoAccount.java b/app/src/main/java/eu/faircode/email/DaoAccount.java index 11088c4966..1a23c2a1bf 100644 --- a/app/src/main/java/eu/faircode/email/DaoAccount.java +++ b/app/src/main/java/eu/faircode/email/DaoAccount.java @@ -149,6 +149,9 @@ public interface DaoAccount { @Query("UPDATE account SET `order` = :order WHERE id = :id") int setAccountOrder(long id, Integer order); + @Query("UPDATE account SET partial_fetch = :partial_fetch WHERE id = :id") + int setAccountPartialFetch(long id, boolean partial_fetch); + @Query("UPDATE account SET warning = :warning WHERE id = :id") int setAccountWarning(long id, String warning);