fix: Clear HiveCollection boxes inside of transaction in order

This makes sure that the deleteFromDisk() method is
called AFTER the clear while
the execution order was
random before which could
lead to the problem that
Hive tries to clear a box after
it got deleted.
This commit is contained in:
Krille 2023-03-31 13:09:01 +02:00
parent da61963d37
commit 4b1bc435e5
No known key found for this signature in database
1 changed files with 22 additions and 22 deletions

View File

@ -242,28 +242,28 @@ class HiveCollectionsDatabase extends DatabaseApi {
} }
@override @override
Future<void> clear() => Future.wait([ Future<void> clear() => transaction(() async {
_clientBox.clear(), await _clientBox.clear();
_accountDataBox.clear(), await _accountDataBox.clear();
_roomsBox.clear(), await _roomsBox.clear();
_roomStateBox.clear(), await _roomStateBox.clear();
_roomMembersBox.clear(), await _roomMembersBox.clear();
_toDeviceQueueBox.clear(), await _toDeviceQueueBox.clear();
_roomAccountDataBox.clear(), await _roomAccountDataBox.clear();
_inboundGroupSessionsBox.clear(), await _inboundGroupSessionsBox.clear();
_outboundGroupSessionsBox.clear(), await _outboundGroupSessionsBox.clear();
_olmSessionsBox.clear(), await _olmSessionsBox.clear();
_userDeviceKeysBox.clear(), await _userDeviceKeysBox.clear();
_userDeviceKeysOutdatedBox.clear(), await _userDeviceKeysOutdatedBox.clear();
_userCrossSigningKeysBox.clear(), await _userCrossSigningKeysBox.clear();
_ssssCacheBox.clear(), await _ssssCacheBox.clear();
_presencesBox.clear(), await _presencesBox.clear();
_timelineFragmentsBox.clear(), await _timelineFragmentsBox.clear();
_eventsBox.clear(), await _eventsBox.clear();
_seenDeviceIdsBox.clear(), await _seenDeviceIdsBox.clear();
_seenDeviceKeysBox.clear(), await _seenDeviceKeysBox.clear();
_collection.deleteFromDisk(), await _collection.deleteFromDisk();
]); });
@override @override
Future<void> clearCache() => transaction(() async { Future<void> clearCache() => transaction(() async {