From 81e822b5abf92f53b1b2a5a1bbad08fbf4ad3dff Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 21 Oct 2019 09:54:20 +0200 Subject: [PATCH] Make sure folder is selected on uid fetch --- app/src/main/java/eu/faircode/email/Core.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index f13c91294d..e5dc2e7240 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -42,6 +42,7 @@ import androidx.preference.PreferenceManager; import com.sun.mail.iap.BadCommandException; import com.sun.mail.iap.CommandFailedException; import com.sun.mail.iap.ConnectionException; +import com.sun.mail.iap.ProtocolException; import com.sun.mail.iap.Response; import com.sun.mail.imap.IMAPFolder; import com.sun.mail.imap.IMAPMessage; @@ -1711,9 +1712,16 @@ class Core { // This is done outside of JavaMail to prevent changed notifications if (!ifolder.isOpen()) throw new FolderClosedException(ifolder, "UID FETCH"); + MessagingException ex = (MessagingException) ifolder.doCommand(new IMAPFolder.ProtocolCommand() { @Override public Object doCommand(IMAPProtocol protocol) { + try { + protocol.select(folder.name); + } catch (ProtocolException ex) { + return new MessagingException("UID FETCH", ex); + } + // Build ranges List> ranges = new ArrayList<>(); long first = -1;