Skip to content

Commit 7105e5d

Browse files
authored
Feature/david/journal mode (#1157)
* changed journal mode when creating db * updated version for internal release * rollback version update * made app debuggable for testing * spotless check * rollback unnecessary changes
1 parent ce97801 commit 7105e5d

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

app/src/main/java/com/duckduckgo/app/di/DatabaseModule.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package com.duckduckgo.app.di
1919
import android.content.Context
2020
import android.webkit.WebViewDatabase
2121
import androidx.room.Room
22+
import androidx.room.RoomDatabase
2223
import com.duckduckgo.app.browser.addtohome.AddToHomeCapabilityDetector
2324
import com.duckduckgo.app.browser.httpauth.RealWebViewHttpAuthStore
2425
import com.duckduckgo.app.browser.httpauth.WebViewHttpAuthStore
@@ -53,6 +54,8 @@ class DatabaseModule {
5354
return Room.databaseBuilder(context, AppDatabase::class.java, "app.db")
5455
.addMigrations(*migrationsProvider.ALL_MIGRATIONS.toTypedArray())
5556
.addCallback(migrationsProvider.BOOKMARKS_DB_ON_CREATE)
57+
.addCallback(migrationsProvider.CHANGE_JOURNAL_ON_OPEN)
58+
.setJournalMode(RoomDatabase.JournalMode.TRUNCATE)
5659
.build()
5760
}
5861

app/src/main/java/com/duckduckgo/app/global/db/AppDatabase.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,12 @@ class MigrationsProvider(
403403
}
404404
}
405405

406+
val CHANGE_JOURNAL_ON_OPEN = object : RoomDatabase.Callback() {
407+
override fun onOpen(db: SupportSQLiteDatabase) {
408+
db.query("PRAGMA journal_mode=DELETE;").use { cursor -> cursor.moveToFirst() }
409+
}
410+
}
411+
406412
val ALL_MIGRATIONS: List<Migration>
407413
get() = listOf(
408414
MIGRATION_1_TO_2,

0 commit comments

Comments
 (0)