fix: wait for pending transactions before db close
This was triggered by some archive decryption test I was writing and possibly also is triggered in production a few times. Waiting for running transactions to complete before closing sounds sensible.
This commit is contained in:
parent
12f45e7687
commit
fec258ef12
|
|
@ -80,7 +80,8 @@ class BoxCollection with ZoneTransactionMixin {
|
||||||
|
|
||||||
Future<void> close() async {
|
Future<void> close() async {
|
||||||
assert(_txnCache == null, 'Database closed while in transaction!');
|
assert(_txnCache == null, 'Database closed while in transaction!');
|
||||||
return _db.close();
|
// Note, zoneTransaction and txnCache are different kinds of transactions.
|
||||||
|
return zoneTransaction(() async => _db.close());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated('use collection.deleteDatabase now')
|
@Deprecated('use collection.deleteDatabase now')
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ class BoxCollection with ZoneTransactionMixin {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
Future<void> close() => _db.close();
|
Future<void> close() => zoneTransaction(() => _db.close());
|
||||||
|
|
||||||
@Deprecated('use collection.deleteDatabase now')
|
@Deprecated('use collection.deleteDatabase now')
|
||||||
static Future<void> delete(String path, [dynamic factory]) =>
|
static Future<void> delete(String path, [dynamic factory]) =>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue