From 76e476e2f9f6e0b7bc0717e5fbe5300ba2569d59 Mon Sep 17 00:00:00 2001 From: Sorunome Date: Tue, 20 Jul 2021 17:56:13 +0200 Subject: [PATCH] fix: Linux failing on attempting to open hive --- .../flutter_famedly_sdk_hive_database.dart | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/utils/matrix_sdk_extensions.dart/flutter_famedly_sdk_hive_database.dart b/lib/utils/matrix_sdk_extensions.dart/flutter_famedly_sdk_hive_database.dart index 57de5d68..24fec306 100644 --- a/lib/utils/matrix_sdk_extensions.dart/flutter_famedly_sdk_hive_database.dart +++ b/lib/utils/matrix_sdk_extensions.dart/flutter_famedly_sdk_hive_database.dart @@ -49,9 +49,12 @@ class FlutterFamedlySdkHiveDatabase extends FamedlySdkHiveDatabase { ); } - final encryptionKey = base64Url.decode( - await secureStorage.read(key: _hiveCipherStorageKey), - ); + // workaround for if we just wrote to the key and it still doesn't exist + final rawEncryptionKey = + await secureStorage.read(key: _hiveCipherStorageKey); + if (rawEncryptionKey == null) throw MissingPluginException(); + + final encryptionKey = base64Url.decode(rawEncryptionKey); hiverCipher = HiveAesCipher(encryptionKey); } on MissingPluginException catch (_) { Logs().i('Hive encryption is not supported on this platform');