mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-05-14 15:08:21 +00:00
Crash proof database: reset if error occurs
This commit is contained in:
parent
c8fd5da2da
commit
e518f4cef8
@ -38,6 +38,7 @@ public class RepoDatabaseHelper extends SQLiteOpenHelper {
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
try {
|
||||
if (oldVersion < 3) {
|
||||
db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
|
||||
db.execSQL(
|
||||
@ -48,6 +49,11 @@ public class RepoDatabaseHelper extends SQLiteOpenHelper {
|
||||
mm.prefs.edit().remove(Const.Key.ETAG_KEY).apply();
|
||||
oldVersion = 3;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// Reset database
|
||||
onDowngrade(db, DATABASE_VER, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -114,6 +114,7 @@ public class SuDatabaseHelper extends SQLiteOpenHelper {
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
try {
|
||||
if (oldVersion == 0) {
|
||||
createTables(db);
|
||||
oldVersion = 3;
|
||||
@ -158,6 +159,10 @@ public class SuDatabaseHelper extends SQLiteOpenHelper {
|
||||
// Hard link our DB globally
|
||||
Shell.su_raw("ln " + getDbFile() + " " + GLOBAL_DB);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
onDowngrade(db, DATABASE_VER, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user