From 24b178773fe6210a679dad56e201e74092cfdcc1 Mon Sep 17 00:00:00 2001 From: Daniel Applebaum Date: Sat, 22 May 2010 17:34:16 +0000 Subject: [PATCH] Make sure prefix is fetched before any call to getCombinedPrefix. --- src/com/fsck/k9/mail/store/ImapStore.java | 34 +++++++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/src/com/fsck/k9/mail/store/ImapStore.java b/src/com/fsck/k9/mail/store/ImapStore.java index d37166560..b14ebfa5c 100644 --- a/src/com/fsck/k9/mail/store/ImapStore.java +++ b/src/com/fsck/k9/mail/store/ImapStore.java @@ -462,11 +462,39 @@ public class ImapStore extends Store this.mName = name; } - public String getPrefixedName() + public String getPrefixedName() throws MessagingException { String prefixedName = ""; if (!K9.INBOX.equalsIgnoreCase(mName)) { + ImapConnection connection = null; + synchronized (this) + { + if (mConnection == null) + { + connection = getConnection(); + } + else + { + connection = mConnection; + } + } + try + { + + connection.open(); + } + catch (IOException ioe) + { + throw new MessagingException("Unable to get IMAP prefix", ioe); + } + finally + { + if (mConnection == null) + { + releaseConnection(connection); + } + } prefixedName = getCombinedPrefix(); } @@ -1954,7 +1982,7 @@ public class ImapStore extends Store { if (o instanceof ImapFolder) { - return ((ImapFolder)o).getPrefixedName().equalsIgnoreCase(getPrefixedName()); + return ((ImapFolder)o).getName().equalsIgnoreCase(getName()); } return super.equals(o); } @@ -1962,7 +1990,7 @@ public class ImapStore extends Store @Override public int hashCode() { - return getPrefixedName().hashCode(); + return getName().hashCode(); } protected ImapStore getStore()