Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
e518f4ce
Commit
e518f4ce
authored
Nov 17, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Crash proof database: reset if error occurs
parent
c8fd5da2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
50 deletions
+61
-50
RepoDatabaseHelper.java
...ava/com/topjohnwu/magisk/database/RepoDatabaseHelper.java
+15
-9
SuDatabaseHelper.java
.../java/com/topjohnwu/magisk/database/SuDatabaseHelper.java
+46
-41
No files found.
app/src/main/java/com/topjohnwu/magisk/database/RepoDatabaseHelper.java
View file @
e518f4ce
...
@@ -38,6 +38,7 @@ public class RepoDatabaseHelper extends SQLiteOpenHelper {
...
@@ -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 {
...
@@ -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
...
...
app/src/main/java/com/topjohnwu/magisk/database/SuDatabaseHelper.java
View file @
e518f4ce
...
@@ -114,6 +114,7 @@ public class SuDatabaseHelper extends SQLiteOpenHelper {
...
@@ -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 {
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment