forked from MarcoBuster/Magisk
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
|
@Override
|
||||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||||
|
try {
|
||||||
if (oldVersion < 3) {
|
if (oldVersion < 3) {
|
||||||
db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
|
db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
|
||||||
db.execSQL(
|
db.execSQL(
|
||||||
|
@ -48,6 +49,11 @@ public class RepoDatabaseHelper extends SQLiteOpenHelper {
|
||||||
mm.prefs.edit().remove(Const.Key.ETAG_KEY).apply();
|
mm.prefs.edit().remove(Const.Key.ETAG_KEY).apply();
|
||||||
oldVersion = 3;
|
oldVersion = 3;
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
// Reset database
|
||||||
|
onDowngrade(db, DATABASE_VER, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -114,6 +114,7 @@ public class SuDatabaseHelper extends SQLiteOpenHelper {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||||
|
try {
|
||||||
if (oldVersion == 0) {
|
if (oldVersion == 0) {
|
||||||
createTables(db);
|
createTables(db);
|
||||||
oldVersion = 3;
|
oldVersion = 3;
|
||||||
|
@ -158,6 +159,10 @@ public class SuDatabaseHelper extends SQLiteOpenHelper {
|
||||||
// Hard link our DB globally
|
// Hard link our DB globally
|
||||||
Shell.su_raw("ln " + getDbFile() + " " + GLOBAL_DB);
|
Shell.su_raw("ln " + getDbFile() + " " + GLOBAL_DB);
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
onDowngrade(db, DATABASE_VER, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue
Block a user