Skip to content

Commit

Permalink
Merge pull request #262 from project-violet/revert-252-db
Browse files Browse the repository at this point in the history
Revert "db: fix database manager for proper initial database downloading"
  • Loading branch information
violet-dev committed Dec 4, 2023
2 parents 4f808c9 + 551b4a7 commit 1a75828
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions lib/database/database.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ class DataBaseManager {

@protected
@mustCallSuper
Future<void> dispose() async {
void dispose() async {
print('close: ${dbPath!}');
await db?.close();
db = null;
if (db != null) db!.close();
}

static Future<DataBaseManager> getInstance() async {
Expand All @@ -38,19 +37,18 @@ class DataBaseManager {
}

static Future<void> reloadInstance() async {
final db = _instance?.db;
_instance?.db = null;
await db?.close();
var dbPath = Platform.isAndroid
? '${(await getApplicationDocumentsDirectory()).path}/data/data.db'
: '${await getDatabasesPath()}/data.db';
_instance = create(dbPath);
}

Future<void> open() async {
Future open() async {
db ??= await openDatabase(dbPath!);
}

Future<void> checkOpen() async {
if (!(db?.isOpen ?? false)) {
db = await openDatabase(dbPath!);
}
Future checkOpen() async {
if (!db!.isOpen) db = await openDatabase(dbPath!);
}

Future<List<Map<String, dynamic>>> query(String str) async {
Expand Down

0 comments on commit 1a75828

Please sign in to comment.