From 50a8d894681ab855fc4e1cb0823a7a112f0278bf Mon Sep 17 00:00:00 2001 From: Wang Li Date: Tue, 23 Jul 2013 14:08:20 +0800 Subject: [PATCH] remoteStore assocciated with account indirectly should also be reseted when acccount was removed. Otherwise, there might be residual data that will affec account being added later. --- src/com/fsck/k9/Preferences.java | 8 ++++++++ src/com/fsck/k9/mail/Store.java | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/src/com/fsck/k9/Preferences.java b/src/com/fsck/k9/Preferences.java index 6f20e5b2f..155547208 100644 --- a/src/com/fsck/k9/Preferences.java +++ b/src/com/fsck/k9/Preferences.java @@ -123,6 +123,14 @@ public class Preferences { accountsInOrder.remove(account); } + try { + account.getRemoteStore().resetRemoteStore(account); + } catch (MessagingException e) { + Log.e(K9.LOG_TAG, "Failed to reset remote store for account " + + account.getUuid()); + e.printStackTrace(); + } + account.delete(this); if (newAccount == account) { diff --git a/src/com/fsck/k9/mail/Store.java b/src/com/fsck/k9/mail/Store.java index 426b67bfe..c60d899e1 100644 --- a/src/com/fsck/k9/mail/Store.java +++ b/src/com/fsck/k9/mail/Store.java @@ -209,5 +209,13 @@ public abstract class Store { return mAccount; } + public void resetRemoteStore(Account account) { + String uri = account.getStoreUri(); + if (uri.startsWith("local")) { + throw new RuntimeException( + "Asked to get non-local Store object but given LocalStore URI"); + } + sStores.remove(uri); + } }