mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-10 09:05:10 +00:00
chore: Delete database after failed to create
This commit is contained in:
parent
ac5bd56c03
commit
4d7d5bf181
1 changed files with 13 additions and 1 deletions
|
@ -18,16 +18,28 @@ import 'package:fluffychat/utils/matrix_sdk_extensions/flutter_hive_collections_
|
||||||
import 'package:fluffychat/utils/platform_infos.dart';
|
import 'package:fluffychat/utils/platform_infos.dart';
|
||||||
|
|
||||||
Future<DatabaseApi> flutterMatrixSdkDatabaseBuilder(Client client) async {
|
Future<DatabaseApi> flutterMatrixSdkDatabaseBuilder(Client client) async {
|
||||||
|
MatrixSdkDatabase? database;
|
||||||
try {
|
try {
|
||||||
final database = await _constructDatabase(client);
|
database = await _constructDatabase(client);
|
||||||
await database.open();
|
await database.open();
|
||||||
return database;
|
return database;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
// Try to delete database so that it can created again on next init:
|
||||||
|
database?.delete().catchError(
|
||||||
|
(e, s) => Logs().w(
|
||||||
|
'Unable to delete database, after failed construction',
|
||||||
|
e,
|
||||||
|
s,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Send error notification:
|
||||||
final l10n = lookupL10n(PlatformDispatcher.instance.locale);
|
final l10n = lookupL10n(PlatformDispatcher.instance.locale);
|
||||||
ClientManager.sendInitNotification(
|
ClientManager.sendInitNotification(
|
||||||
l10n.initAppError,
|
l10n.initAppError,
|
||||||
l10n.databaseBuildErrorBody(AppConfig.newIssueUrl.toString()),
|
l10n.databaseBuildErrorBody(AppConfig.newIssueUrl.toString()),
|
||||||
);
|
);
|
||||||
|
|
||||||
return FlutterHiveCollectionsDatabase.databaseBuilder(client);
|
return FlutterHiveCollectionsDatabase.databaseBuilder(client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue