feat: Make possible to overwrite boxcollection opener in Hive Collections Database

This commit is contained in:
Krille 2023-03-20 08:01:51 +01:00
parent 6ab9483d73
commit efe8e7e5ac
No known key found for this signature in database
1 changed files with 13 additions and 2 deletions

View File

@ -38,6 +38,12 @@ class HiveCollectionsDatabase extends DatabaseApi {
final String name;
final String? path;
final HiveCipher? key;
final Future<BoxCollection> Function(
String name,
Set<String> boxNames, {
String? path,
HiveCipher? key,
}) collectionFactory;
late BoxCollection _collection;
late CollectionBox<String> _clientBox;
late CollectionBox<Map> _accountDataBox;
@ -118,13 +124,18 @@ class HiveCollectionsDatabase extends DatabaseApi {
String get _seenDeviceKeysBoxName => 'box_seen_device_keys';
HiveCollectionsDatabase(this.name, this.path, {this.key});
HiveCollectionsDatabase(
this.name,
this.path, {
this.key,
this.collectionFactory = BoxCollection.open,
});
@override
int get maxFileSize => 0;
Future<void> open() async {
_collection = await BoxCollection.open(
_collection = await collectionFactory(
name,
{
_clientBoxName,