mirror of
https://github.com/ankidroid/Anki-Android.git
synced 2024-09-20 03:52:15 +02:00
fix: Don't crash if no WebView
After a bad init, we tested to see the database version
If there was no WebView, AnkiDroidApp hadn't performed an init
This caused a path where `new Db(path)` could be called when the
database wasn't created, using a Java style database init without
handling creating the `col` table
We then crashed as there was no default deck
Related: 9226
(cherry picked from commit 876180e614
)
This commit is contained in:
parent
4f30c2c2a7
commit
0a854a546c
@ -32,6 +32,7 @@ import com.ichi2.utils.JSONException;
|
||||
import com.ichi2.utils.JSONObject;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
@ -57,6 +58,9 @@ public class Storage {
|
||||
/** Helper method for when the collection can't be opened */
|
||||
public static int getDatabaseVersion(String path) throws UnknownDatabaseVersionException {
|
||||
try {
|
||||
if (!new File(path).exists()) {
|
||||
throw new UnknownDatabaseVersionException(new FileNotFoundException(path));
|
||||
}
|
||||
DB db = new DB(path);
|
||||
int result = db.queryScalar("SELECT ver FROM col");
|
||||
db.close();
|
||||
|
Loading…
Reference in New Issue
Block a user