From 7ad14465d2673530d9bcc3b61a402028cf0886a3 Mon Sep 17 00:00:00 2001 From: Krille Fear Date: Sun, 21 Nov 2021 12:01:53 +0100 Subject: [PATCH] chore: Update SDK and remove boxes on corruption --- .../fluffybox_database.dart | 13 ++++++++++++- pubspec.lock | 4 ++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/utils/matrix_sdk_extensions.dart/fluffybox_database.dart b/lib/utils/matrix_sdk_extensions.dart/fluffybox_database.dart index 65d573ee..29f785b5 100644 --- a/lib/utils/matrix_sdk_extensions.dart/fluffybox_database.dart +++ b/lib/utils/matrix_sdk_extensions.dart/fluffybox_database.dart @@ -12,6 +12,9 @@ import 'package:hive_flutter/hive_flutter.dart'; import 'package:matrix/matrix.dart'; import 'package:path_provider/path_provider.dart'; +import '../client_manager.dart'; +import '../famedlysdk_store.dart'; + class FlutterFluffyBoxDatabase extends FluffyBoxDatabase { FlutterFluffyBoxDatabase( String name, @@ -60,7 +63,15 @@ class FlutterFluffyBoxDatabase extends FluffyBoxDatabase { await _findDatabasePath(client), key: hiverCipher, ); - await db.open(); + try { + await db.open(); + } catch (_) { + Logs().w('Unable to open FluffyBox. Delete database and storage key...'); + await Store().deleteItem(ClientManager.clientNamespace); + const FlutterSecureStorage().delete(key: _cipherStorageKey); + await db.clear(); + rethrow; + } Logs().d('FluffyBox is ready'); return db; } diff --git a/pubspec.lock b/pubspec.lock index 7932827c..4b21a797 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -364,7 +364,7 @@ packages: name: fluffybox url: "https://pub.dartlang.org" source: hosted - version: "0.2.6" + version: "0.3.1" flutter: dependency: "direct main" description: flutter @@ -782,7 +782,7 @@ packages: description: path: "." ref: "krille/idb" - resolved-ref: "74037fb8ae0f4c4e1ac946d7c2057bf6e2da7aaf" + resolved-ref: e4d9ee12a84d804d3de190db6fe597eea72bd094 url: "https://gitlab.com/famedly/company/frontend/famedlysdk.git" source: git version: "0.7.0-nullsafety.6"