From 12bdddee03641d11c51b039f99d18b8d6a92df3e Mon Sep 17 00:00:00 2001 From: Sorunome Date: Tue, 16 Jun 2020 14:26:37 +0200 Subject: [PATCH] Better format switching to WAL mode --- lib/src/database/database.dart | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/lib/src/database/database.dart b/lib/src/database/database.dart index 3aa14dc..8abde1d 100644 --- a/lib/src/database/database.dart +++ b/lib/src/database/database.dart @@ -4,7 +4,6 @@ import 'dart:convert'; import 'package:famedlysdk/famedlysdk.dart' as sdk; import 'package:famedlysdk/matrix_api.dart' as api; import 'package:olm/olm.dart' as olm; -import 'package:pedantic/pedantic.dart'; import '../../matrix_api.dart'; @@ -21,20 +20,6 @@ class Database extends _$Database { int get maxFileSize => 1 * 1024 * 1024; - @override - Future beforeOpen( - QueryExecutor executor, OpeningDetails details) async { - await super.beforeOpen(executor, details); - if (executor.dialect == SqlDialect.sqlite) { - unawaited(customSelect('PRAGMA journal_mode=WAL').get().then((ret) { - if (ret.isNotEmpty) { - print('[Moor] Switched database to mode ' + - ret.first.data['journal_mode'].toString()); - } - })); - } - } - @override MigrationStrategy get migration => MigrationStrategy( onCreate: (Migrator m) { @@ -61,6 +46,15 @@ class Database extends _$Database { await m.createTable(outboundGroupSessions); } }, + beforeOpen: (_) async { + if (executor.dialect == SqlDialect.sqlite) { + final ret = await customSelect('PRAGMA journal_mode=WAL').get(); + if (ret.isNotEmpty) { + print('[Moor] Switched database to mode ' + + ret.first.data['journal_mode'].toString()); + } + } + }, ); Future getClient(String name) async {