From e3ee1cc4b2260fe561bcdcbf771dabf5ee1f8464 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 21 Jan 2020 08:16:32 +0100 Subject: [PATCH] Modify WAL checkpoint in debug version only --- app/src/main/java/eu/faircode/email/DB.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/DB.java b/app/src/main/java/eu/faircode/email/DB.java index ee2390453c..5f8be1cedc 100644 --- a/app/src/main/java/eu/faircode/email/DB.java +++ b/app/src/main/java/eu/faircode/email/DB.java @@ -110,12 +110,14 @@ public abstract class DB extends RoomDatabase { @Override public void init(@NonNull DatabaseConfiguration configuration) { // https://www.sqlite.org/pragma.html#pragma_wal_autocheckpoint - File dbfile = configuration.context.getDatabasePath(DB_NAME); - if (dbfile.exists()) { - try (SQLiteDatabase db = SQLiteDatabase.openDatabase(dbfile.getPath(), null, SQLiteDatabase.OPEN_READWRITE)) { - Log.i("DB checkpoint=" + DB_CHECKPOINT); - try (Cursor cursor = db.rawQuery("PRAGMA wal_autocheckpoint=" + DB_CHECKPOINT + ";", null)) { - cursor.moveToNext(); // required + if (BuildConfig.DEBUG) { + File dbfile = configuration.context.getDatabasePath(DB_NAME); + if (dbfile.exists()) { + try (SQLiteDatabase db = SQLiteDatabase.openDatabase(dbfile.getPath(), null, SQLiteDatabase.OPEN_READWRITE)) { + Log.i("DB checkpoint=" + DB_CHECKPOINT); + try (Cursor cursor = db.rawQuery("PRAGMA wal_autocheckpoint=" + DB_CHECKPOINT + ";", null)) { + cursor.moveToNext(); // required + } } } }