mirror of
https://github.com/immich-app/drift.git
synced 2026-09-30 13:22:57 +08:00
add isolateDebugLog to DriftNativeOptions
This commit is contained in:
@@ -39,12 +39,12 @@ final class DriftWebOptions {
|
||||
final FutureOr<Uint8List?> Function()? initializeDatabase;
|
||||
|
||||
/// Create web-specific drift options.
|
||||
DriftWebOptions(
|
||||
{required this.sqlite3Wasm,
|
||||
required this.driftWorker,
|
||||
this.onResult,
|
||||
this.initializeDatabase,
|
||||
});
|
||||
DriftWebOptions({
|
||||
required this.sqlite3Wasm,
|
||||
required this.driftWorker,
|
||||
this.onResult,
|
||||
this.initializeDatabase,
|
||||
});
|
||||
}
|
||||
|
||||
/// Options used to open drift databases on native platforms (outside of the
|
||||
@@ -67,6 +67,10 @@ final class DriftNativeOptions {
|
||||
/// may be used on multiple isolates.
|
||||
final bool shareAcrossIsolates;
|
||||
|
||||
/// Setting the [isolateDebugLog] is only helpful when debugging drift itself.
|
||||
/// It will print messages exchanged between the Drift server and the client.
|
||||
final bool isolateDebugLog;
|
||||
|
||||
/// An optional callback returning a custom database path to be used by drift.
|
||||
///
|
||||
/// By default, drift uses the `getApplicationDocumentsDirectory()` function
|
||||
@@ -129,6 +133,7 @@ final class DriftNativeOptions {
|
||||
/// platforms.
|
||||
const DriftNativeOptions({
|
||||
this.shareAcrossIsolates = false,
|
||||
this.isolateDebugLog = false,
|
||||
this.databasePath,
|
||||
this.databaseDirectory,
|
||||
this.tempDirectoryPath,
|
||||
|
||||
@@ -7,8 +7,8 @@ import 'package:drift/drift.dart';
|
||||
import 'package:drift/isolate.dart';
|
||||
import 'package:drift/native.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:sqlite3/sqlite3.dart';
|
||||
import 'package:sqlite3_flutter_libs/sqlite3_flutter_libs.dart';
|
||||
|
||||
@@ -82,7 +82,10 @@ QueryExecutor driftDatabase({
|
||||
case final port?) {
|
||||
final isolate = DriftIsolate.fromConnectPort(port);
|
||||
try {
|
||||
return await isolate.connect(connectTimeout: connectTimeout);
|
||||
return await isolate.connect(
|
||||
connectTimeout: connectTimeout,
|
||||
isolateDebugLog: native.isolateDebugLog,
|
||||
);
|
||||
} on TimeoutException {
|
||||
// Isolate has stopped shortly after the register call. It should
|
||||
// also remove the port mapping, so we can just try again in another
|
||||
@@ -124,7 +127,9 @@ QueryExecutor driftDatabase({
|
||||
// due to a race condition (in which case it exits).
|
||||
final first = await firstMessage;
|
||||
if (first case SendPort port) {
|
||||
return await DriftIsolate.fromConnectPort(port).connect();
|
||||
return await DriftIsolate.fromConnectPort(port).connect(
|
||||
isolateDebugLog: native.isolateDebugLog,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user