mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-03-27 01:14:43 +01:00
Set the drift logger also in isolates
This commit is contained in:
parent
3387378181
commit
2e596fbd11
2 changed files with 8 additions and 7 deletions
|
@ -52,7 +52,7 @@ Future<void> init(InitIsolateType isolateType) async {
|
|||
}
|
||||
|
||||
initLog();
|
||||
_initDrift();
|
||||
initDrift();
|
||||
_initKiwi();
|
||||
await _initPref();
|
||||
await _initAccountPrefs();
|
||||
|
@ -111,8 +111,8 @@ void initLog() {
|
|||
});
|
||||
}
|
||||
|
||||
void _initDrift() {
|
||||
driftRuntimeOptions.debugPrint = _debugPrintSql;
|
||||
void initDrift() {
|
||||
driftRuntimeOptions.debugPrint = (log) => debugPrint(log, wrapWidth: 1024);
|
||||
}
|
||||
|
||||
Future<void> _initPref() async {
|
||||
|
@ -209,9 +209,5 @@ Future<sql.SqliteDb> _createDb(InitIsolateType isolateType) async {
|
|||
}
|
||||
}
|
||||
|
||||
void _debugPrintSql(String log) {
|
||||
_log.finer(log);
|
||||
}
|
||||
|
||||
final _log = Logger("app_init");
|
||||
var _hasInitedInThisIsolate = false;
|
||||
|
|
|
@ -3,6 +3,7 @@ import 'dart:isolate';
|
|||
import 'package:drift/drift.dart';
|
||||
import 'package:drift/isolate.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:nc_photos/app_init.dart' as app_init;
|
||||
import 'package:nc_photos/entity/sqlite_table.dart';
|
||||
import 'package:nc_photos/mobile/platform.dart'
|
||||
if (dart.library.html) 'package:nc_photos/web/platform.dart' as platform;
|
||||
|
@ -57,6 +58,8 @@ Future<DriftIsolate> _createDriftIsolate() async {
|
|||
}
|
||||
|
||||
void _startBackground(_IsolateStartRequest request) {
|
||||
app_init.initDrift();
|
||||
|
||||
// this is the entry point from the background isolate! Let's create
|
||||
// the database from the path we received
|
||||
final executor = platform.openSqliteConnectionWithArgs(request.platformArgs);
|
||||
|
@ -73,6 +76,8 @@ void _startBackground(_IsolateStartRequest request) {
|
|||
}
|
||||
|
||||
Future<U> _computeWithDbImpl<T, U>(_ComputeWithDbMessage<T, U> message) async {
|
||||
app_init.initDrift();
|
||||
|
||||
// we don't use driftIsolate because opening a DB normally is found to perform
|
||||
// better
|
||||
final sqliteDb = SqliteDb(
|
||||
|
|
Loading…
Add table
Reference in a new issue