Delete only corrupt databases

pull/214/head
M66B 1 year ago
parent 2c4eb99d6a
commit 33be622f3e

@ -18,6 +18,7 @@ package androidx.sqlite.db.framework
import android.content.Context
import android.database.DatabaseErrorHandler
import android.database.sqlite.SQLiteDatabase
import android.database.sqlite.SQLiteDatabaseCorruptException
import android.database.sqlite.SQLiteException
import android.database.sqlite.SQLiteOpenHelper
import android.os.Build
@ -204,7 +205,7 @@ internal class FrameworkSQLiteOpenHelper @JvmOverloads constructor(
}
// If callback exception is not an SQLiteException, then more certainly it is not
// recoverable.
if (cause !is SQLiteException) {
if (cause !is SQLiteDatabaseCorruptException) {
throw cause
}
} else if (openRetryError is SQLiteException) {

@ -522,7 +522,7 @@ public abstract class DB extends RoomDatabase {
dropTriggers(db);
createTriggers(db);
} catch (SQLiteException ex) {
} catch (Throwable ex) {
/*
at eu.faircode.email.DB$6.onOpen(DB.java:522)
at eu.faircode.email.DB_Impl$1.onOpen(DB_Impl.java:171)
@ -538,10 +538,7 @@ public abstract class DB extends RoomDatabase {
*/
Log.e(ex);
// FrameworkSQLiteOpenHelper.innerGetDatabase will delete the database
if (ex instanceof SQLiteDatabaseCorruptException)
throw ex;
else
throw new RuntimeException("Open failed", ex);
throw ex;
}
}

Loading…
Cancel
Save