From 8a9be94fc6939fc7a35a1c9bddb301dd02b631f6 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 20 Sep 2020 10:10:31 +0200 Subject: [PATCH] Handle store closed exception --- .../java/eu/faircode/email/ServiceSynchronize.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index 73690d3eaf..5ad53fe3a6 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -1325,7 +1325,16 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences db.folder().setFolderState(folder.id, "connecting"); - ifolder = iservice.getStore().getFolder(folder.name); + // Handle store closed exception + try { + ifolder = iservice.getStore().getFolder(folder.name); + } catch (IllegalStateException ex) { + if ("Not connected".equals(ex.getMessage())) + return; + else + throw ex; + } + try { ifolder.open(Folder.READ_WRITE); } catch (ReadOnlyFolderException ex) {