mirror of
https://github.com/krille-chan/fluffychat.git
synced 2026-07-16 17:27:11 +02:00
chore: retry create database and expect crash on ios
This commit is contained in:
@@ -20,38 +20,32 @@ import 'sqlcipher_stub.dart'
|
||||
if (dart.library.io) 'package:sqlcipher_flutter_libs/sqlcipher_flutter_libs.dart';
|
||||
|
||||
Future<DatabaseApi> flutterMatrixSdkDatabaseBuilder(String clientName) async {
|
||||
MatrixSdkDatabase? database;
|
||||
try {
|
||||
database = await _constructDatabase(clientName);
|
||||
await database.open();
|
||||
return database;
|
||||
return await _constructDatabase(clientName);
|
||||
} catch (e, s) {
|
||||
Logs().wtf('Unable to construct database!', e, s);
|
||||
|
||||
try {
|
||||
// Send error notification:
|
||||
final l10n = await lookupL10n(PlatformDispatcher.instance.locale);
|
||||
ClientManager.sendInitNotification(l10n.initAppError, e.toString());
|
||||
// We expect that the database cannot be open on iOS 2.8.0 due to that
|
||||
// the team ID has changed and te app can no longer access the database
|
||||
// key in the iOS keychain. This should be removed from 2.9.0 on.
|
||||
if (!PlatformInfos.isIOS) {
|
||||
ClientManager.sendInitNotification(l10n.initAppError, e.toString());
|
||||
}
|
||||
} catch (e, s) {
|
||||
Logs().e('Unable to send error notification', e, s);
|
||||
}
|
||||
|
||||
// Try to delete database so that it can created again on next init:
|
||||
database?.delete().catchError(
|
||||
(e, s) => Logs().wtf(
|
||||
'Unable to delete database, after failed construction',
|
||||
e,
|
||||
s,
|
||||
),
|
||||
);
|
||||
|
||||
// Delete database file:
|
||||
if (!kIsWeb) {
|
||||
final dbFile = File(await _getDatabasePath(clientName));
|
||||
if (await dbFile.exists()) await dbFile.delete();
|
||||
}
|
||||
|
||||
rethrow;
|
||||
// Try again
|
||||
return await _constructDatabase(clientName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user