From 2e4a5f62e408339944b4e624043dad793f6c0694 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Tue, 16 Aug 2022 08:03:03 +0200 Subject: [PATCH] fix: Linux crash on secure storage usage --- .../matrix_sdk_extensions.dart/fluffybox_database.dart | 8 +++++--- .../flutter_hive_collections_database.dart | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/utils/matrix_sdk_extensions.dart/fluffybox_database.dart b/lib/utils/matrix_sdk_extensions.dart/fluffybox_database.dart index 1d966ee7..5c15d620 100644 --- a/lib/utils/matrix_sdk_extensions.dart/fluffybox_database.dart +++ b/lib/utils/matrix_sdk_extensions.dart/fluffybox_database.dart @@ -58,9 +58,11 @@ class FlutterFluffyBoxDatabase extends FluffyBoxDatabase { hiverCipher = fluffybox.HiveAesCipher(base64Url.decode(rawEncryptionKey)); } on MissingPluginException catch (_) { Logs().i('FluffyBox encryption is not supported on this platform'); - } catch (_) { - const FlutterSecureStorage().delete(key: _cipherStorageKey); - rethrow; + } catch (e, s) { + const FlutterSecureStorage() + .delete(key: _cipherStorageKey) + .catchError((_) {}); + Logs().w('Unable to init FluffyBox encryption', e, s); } // ignore: deprecated_member_use diff --git a/lib/utils/matrix_sdk_extensions.dart/flutter_hive_collections_database.dart b/lib/utils/matrix_sdk_extensions.dart/flutter_hive_collections_database.dart index 0f775672..4a0171d8 100644 --- a/lib/utils/matrix_sdk_extensions.dart/flutter_hive_collections_database.dart +++ b/lib/utils/matrix_sdk_extensions.dart/flutter_hive_collections_database.dart @@ -51,9 +51,11 @@ class FlutterHiveCollectionsDatabase extends HiveCollectionsDatabase { hiverCipher = HiveAesCipher(base64Url.decode(rawEncryptionKey)); } on MissingPluginException catch (_) { Logs().i('Hive encryption is not supported on this platform'); - } catch (_) { - const FlutterSecureStorage().delete(key: _cipherStorageKey); - rethrow; + } catch (e, s) { + const FlutterSecureStorage() + .delete(key: _cipherStorageKey) + .catchError((_) {}); + Logs().w('Unable to init Hive encryption', e, s); } final db = FlutterHiveCollectionsDatabase(