From dda8395c7a5e2046087e1fe88ca8e6d8149665a7 Mon Sep 17 00:00:00 2001 From: cketti Date: Tue, 16 Jul 2013 16:54:26 +0200 Subject: [PATCH] Make sure we always have the ID of a folder when fetching the unread/flagged count --- src/com/fsck/k9/mail/store/LocalStore.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/com/fsck/k9/mail/store/LocalStore.java b/src/com/fsck/k9/mail/store/LocalStore.java index 9de4458ed..47b4b97a8 100644 --- a/src/com/fsck/k9/mail/store/LocalStore.java +++ b/src/com/fsck/k9/mail/store/LocalStore.java @@ -1521,6 +1521,10 @@ public class LocalStore extends Store implements Serializable { @Override public int getUnreadMessageCount() throws MessagingException { + if (mFolderId == -1) { + open(OpenMode.READ_WRITE); + } + try { return database.execute(false, new DbCallback() { @Override @@ -1548,7 +1552,7 @@ public class LocalStore extends Store implements Serializable { @Override public int getFlaggedMessageCount() throws MessagingException { - if (!isOpen()) { + if (mFolderId == -1) { open(OpenMode.READ_WRITE); }