mirror of
https://github.com/etesync/android
synced 2025-01-10 15:51:08 +00:00
EtebaseCache: fix crash when removing and re-adding (sometimes).
Essentially the problem was that when we were removing the account, the cache directory was removed. Though then when readding the account, we would get the cache handler from our handler cache, which would already be init, so it'd assume the directory already exists. This was only relevant if there were network errors because otherwise the sync would also happen it the background which would create the missing dirs anyway. The solution: remove the object from the handler cache when removing account.
This commit is contained in:
parent
02a758739d
commit
918f30965d
@ -38,7 +38,7 @@ class EtebaseLocalCache private constructor(context: Context, username: String)
|
||||
return File(colDir, "items")
|
||||
}
|
||||
|
||||
fun clearUserCache() {
|
||||
private fun clearUserCache() {
|
||||
filesDir.deleteRecursively()
|
||||
}
|
||||
|
||||
@ -153,6 +153,12 @@ class EtebaseLocalCache private constructor(context: Context, username: String)
|
||||
}
|
||||
}
|
||||
|
||||
fun clearUserCache(context: Context, username: String) {
|
||||
val localCache = getInstance(context, username)
|
||||
localCache.clearUserCache()
|
||||
localCacheCache.remove(username)
|
||||
}
|
||||
|
||||
// FIXME: If we ever cache this we need to cache bust on changePassword
|
||||
fun getEtebase(context: Context, httpClient: OkHttpClient, settings: AccountSettings): Account {
|
||||
val client = Client.create(httpClient, settings.uri?.toString())
|
||||
|
@ -562,8 +562,7 @@ class AccountActivity : BaseActivity(), Toolbar.OnMenuItemClickListener, PopupMe
|
||||
Logger.log.warning(e.toString())
|
||||
}
|
||||
} else {
|
||||
val etebaseLocalCache = EtebaseLocalCache.getInstance(this@AccountActivity, account.name)
|
||||
etebaseLocalCache.clearUserCache()
|
||||
EtebaseLocalCache.clearUserCache(this@AccountActivity, account.name)
|
||||
|
||||
try {
|
||||
val httpClient = HttpClient.Builder(this@AccountActivity).build()
|
||||
|
Loading…
Reference in New Issue
Block a user