mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-17 21:32:26 -05:00
Refactor code to remove remote store references when deleting accounts
This commit is contained in:
parent
231367b448
commit
01336944ec
@ -12,7 +12,7 @@ import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.util.Log;
|
||||
|
||||
import com.fsck.k9.mail.MessagingException;
|
||||
import com.fsck.k9.mail.Store;
|
||||
import com.fsck.k9.preferences.Editor;
|
||||
import com.fsck.k9.preferences.Storage;
|
||||
|
||||
@ -126,11 +126,9 @@ public class Preferences {
|
||||
}
|
||||
|
||||
try {
|
||||
account.getRemoteStore().resetRemoteStore(account);
|
||||
} catch (MessagingException e) {
|
||||
Log.e(K9.LOG_TAG, "Failed to reset remote store for account "
|
||||
+ account.getUuid());
|
||||
e.printStackTrace();
|
||||
Store.removeRemoteInstance(account);
|
||||
} catch (Exception e) {
|
||||
Log.e(K9.LOG_TAG, "Failed to reset remote store for account " + account.getUuid(), e);
|
||||
}
|
||||
|
||||
account.delete(this);
|
||||
|
@ -111,6 +111,23 @@ public abstract class Store {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Release reference to a remote mail store instance.
|
||||
*
|
||||
* @param account
|
||||
* {@link Account} instance that is used to get the remote mail store instance.
|
||||
*/
|
||||
public synchronized static void removeRemoteInstance(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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes the contents of store-specific URIs and puts them into a {@link ServerSettings}
|
||||
* object.
|
||||
@ -208,14 +225,4 @@ public abstract class Store {
|
||||
public Account getAccount() {
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user