From 9edbab9845b8a1182dee35121a6348537fc657f7 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Thu, 7 Mar 2019 18:47:17 -0500 Subject: Delete dbflow data on migration --- app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'app/src/main/kotlin/com/pitchedapps') diff --git a/app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt index 24e9c548..24b848fe 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt @@ -108,11 +108,17 @@ class StartActivity : KauBaseActivity() { private suspend fun migrate() = withContext(Dispatchers.IO) { if (cookieDao.selectAll().isNotEmpty()) return@withContext val cookies = (select from CookieModel::class).queryList().map { CookieEntity(it.id, it.name, it.cookie) } - cookieDao.save(cookies) + if (cookies.isNotEmpty()) { + cookieDao.save(cookies) + L._d { "Migrated cookies ${cookieDao.selectAll()}" } + } val tabs = (select from FbTabModel::class).queryList().map(FbTabModel::tab) - tabDao.save(tabs) - L._d { "Migrated cookies ${cookieDao.selectAll()}" } - L._d { "Migrated tabs ${tabDao.selectAll()}" } + if (tabs.isNotEmpty()) { + tabDao.save(tabs) + L._d { "Migrated tabs ${tabDao.selectAll()}" } + } + deleteDatabase("Cookies.db") + deleteDatabase("FrostTabs.db") } private fun showInvalidWebView() = -- cgit v1.2.3