mirror of https://github.com/AMT-Cheif/drift.git
Report more errors when database is opened
This commit is contained in:
parent
3c56e0ad6e
commit
a17ad13542
|
@ -240,14 +240,26 @@ class DelegatedDatabase extends QueryExecutor with _ExecutorWithQueryDelegate {
|
|||
logStatements ??= false;
|
||||
}
|
||||
|
||||
var _ensureOpenCalledCounter = 0; // todo remove
|
||||
|
||||
@override
|
||||
Future<bool> ensureOpen() {
|
||||
return _openingLock.synchronized(() async {
|
||||
final alreadyOpen = await delegate.isOpen;
|
||||
if (alreadyOpen) return true;
|
||||
final call = ++_ensureOpenCalledCounter;
|
||||
print('ensure_open_$call: called');
|
||||
|
||||
return _openingLock.synchronized(() async {
|
||||
print('ensure_open_$call: lock aquired');
|
||||
final alreadyOpen = await delegate.isOpen;
|
||||
if (alreadyOpen) {
|
||||
print('ensure_open_$call: was already open');
|
||||
return true;
|
||||
}
|
||||
|
||||
print('ensure_open_$call: opening database');
|
||||
await delegate.open(databaseInfo);
|
||||
print('ensure_open_$call: running migrations');
|
||||
await _runMigrations();
|
||||
print('ensure_open_$call: done with opening');
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -53,11 +53,11 @@ class _SqfliteDelegate extends DatabaseDelegate with _SqfliteExecutor {
|
|||
|
||||
@override
|
||||
Future<void> open([GeneratedDatabase db]) async {
|
||||
print('uses fix for the opening problem.');
|
||||
assert(
|
||||
!_debugIsOpening && !isOpen,
|
||||
'Database opened multiple times, this should never happen. '
|
||||
'Please report this at https://github.com/simolus3/moor/issues/135 to help fix this!');
|
||||
'Please report this at https://github.com/simolus3/moor/issues/135 to help fix this!'
|
||||
'Db already opened: $isOpen. Other operation in progress: $_debugIsOpening');
|
||||
_debugIsOpening = true;
|
||||
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue