From 72ede04868ed03aa3be99dd7b4cecc9cee606826 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 17 Apr 2020 16:34:43 +0200 Subject: [PATCH] Check if folders are actually alive --- app/src/main/java/eu/faircode/email/Core.java | 10 ++++++++++ .../java/eu/faircode/email/ServiceSynchronize.java | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index 527de8cd66..cdfcd7940c 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -586,6 +586,16 @@ class Core { }); } + static boolean isAlive(IMAPFolder ifolder) { + try { + noop(ifolder); + } catch (MessagingException ex) { + Log.i(ifolder.getFullName(), ex); + return false; + } + return true; + } + private static void onSeen(Context context, JSONArray jargs, EntityFolder folder, EntityMessage message, IMAPFolder ifolder) throws MessagingException, JSONException { // Mark message (un)seen DB db = DB.getInstance(context); diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index 3a0b0d381f..5f62562f90 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -1346,7 +1346,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences if (folder.synchronize) if (!folder.poll && capIdle) { // Sends folder NOOP - if (!mapFolders.get(folder).isOpen()) + if (!Core.isAlive(mapFolders.get(folder))) throw new StoreClosedException(iservice.getStore(), folder.name); } else { if (folder.poll_count == 0)