From efe8e7e5acd68f96ce0c69b52f578699aef7803e Mon Sep 17 00:00:00 2001 From: Krille Date: Mon, 20 Mar 2023 08:01:51 +0100 Subject: [PATCH] feat: Make possible to overwrite boxcollection opener in Hive Collections Database --- lib/src/database/hive_collections_database.dart | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/src/database/hive_collections_database.dart b/lib/src/database/hive_collections_database.dart index 67ed8e69..6bfb8b04 100644 --- a/lib/src/database/hive_collections_database.dart +++ b/lib/src/database/hive_collections_database.dart @@ -38,6 +38,12 @@ class HiveCollectionsDatabase extends DatabaseApi { final String name; final String? path; final HiveCipher? key; + final Future Function( + String name, + Set boxNames, { + String? path, + HiveCipher? key, + }) collectionFactory; late BoxCollection _collection; late CollectionBox _clientBox; late CollectionBox _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 open() async { - _collection = await BoxCollection.open( + _collection = await collectionFactory( name, { _clientBoxName,