diff options
author | Allan Wang <me@allanwang.ca> | 2019-03-07 18:47:17 -0500 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2019-03-07 18:47:17 -0500 |
commit | 9edbab9845b8a1182dee35121a6348537fc657f7 (patch) | |
tree | 6a43d5702ae891e8ea41fe7551acfa1aa618ab4d /app/src/main/kotlin/com | |
parent | f038ed790f74d496098575d4e9112f958d9cd6c9 (diff) | |
download | frost-9edbab9845b8a1182dee35121a6348537fc657f7.tar.gz frost-9edbab9845b8a1182dee35121a6348537fc657f7.tar.bz2 frost-9edbab9845b8a1182dee35121a6348537fc657f7.zip |
Delete dbflow data on migration
Diffstat (limited to 'app/src/main/kotlin/com')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt | 14 |
1 files changed, 10 insertions, 4 deletions
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() = |