|
|
|
|
@ -1,20 +1,16 @@
|
|
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
|
|
import 'package:fluffychat/pangea/utils/error_handler.dart';
|
|
|
|
|
import 'package:fluffychat/utils/matrix_sdk_extensions/flutter_hive_collections_database.dart';
|
|
|
|
|
import 'package:fluffychat/utils/platform_infos.dart';
|
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
|
|
|
|
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|
|
|
|
import 'package:matrix/matrix.dart';
|
|
|
|
|
import 'package:path/path.dart';
|
|
|
|
|
import 'package:path_provider/path_provider.dart';
|
|
|
|
|
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
|
|
|
|
|
import 'package:universal_html/html.dart' as html;
|
|
|
|
|
|
|
|
|
|
import 'package:fluffychat/config/app_config.dart';
|
|
|
|
|
import 'package:fluffychat/utils/client_manager.dart';
|
|
|
|
|
import 'package:fluffychat/utils/matrix_sdk_extensions/flutter_hive_collections_database.dart';
|
|
|
|
|
import 'package:fluffychat/utils/platform_infos.dart';
|
|
|
|
|
import 'cipher.dart';
|
|
|
|
|
|
|
|
|
|
import 'sqlcipher_stub.dart'
|
|
|
|
|
if (dart.library.io) 'package:sqlcipher_flutter_libs/sqlcipher_flutter_libs.dart';
|
|
|
|
|
|
|
|
|
|
@ -24,25 +20,49 @@ Future<DatabaseApi> flutterMatrixSdkDatabaseBuilder(Client client) async {
|
|
|
|
|
database = await _constructDatabase(client);
|
|
|
|
|
await database.open();
|
|
|
|
|
return database;
|
|
|
|
|
} catch (e) {
|
|
|
|
|
// #Pangea
|
|
|
|
|
// } catch (e) {
|
|
|
|
|
} catch (e, s) {
|
|
|
|
|
ErrorHandler.logError(
|
|
|
|
|
e: e,
|
|
|
|
|
s: s,
|
|
|
|
|
m: "Failed to open matrix sdk database. Openning fallback database.",
|
|
|
|
|
);
|
|
|
|
|
// Pangea#
|
|
|
|
|
// 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,
|
|
|
|
|
),
|
|
|
|
|
// #Pangea
|
|
|
|
|
// (e, s) => Logs().w(
|
|
|
|
|
// 'Unable to delete database, after failed construction',
|
|
|
|
|
// e,
|
|
|
|
|
// s,
|
|
|
|
|
// ),
|
|
|
|
|
(e, s) {
|
|
|
|
|
Logs().w(
|
|
|
|
|
'Unable to delete database, after failed construction',
|
|
|
|
|
e,
|
|
|
|
|
s,
|
|
|
|
|
);
|
|
|
|
|
ErrorHandler.logError(
|
|
|
|
|
e: e,
|
|
|
|
|
s: s,
|
|
|
|
|
m: "Failed to delete matrix database after failed construction.",
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
// Pangea#
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Send error notification:
|
|
|
|
|
final l10n = lookupL10n(PlatformDispatcher.instance.locale);
|
|
|
|
|
ClientManager.sendInitNotification(
|
|
|
|
|
l10n.initAppError,
|
|
|
|
|
l10n.databaseBuildErrorBody(
|
|
|
|
|
AppConfig.newIssueUrl.toString(),
|
|
|
|
|
e.toString(),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
// #Pangea
|
|
|
|
|
// final l10n = lookupL10n(PlatformDispatcher.instance.locale);
|
|
|
|
|
// ClientManager.sendInitNotification(
|
|
|
|
|
// l10n.initAppError,
|
|
|
|
|
// l10n.databaseBuildErrorBody(
|
|
|
|
|
// AppConfig.newIssueUrl.toString(),
|
|
|
|
|
// e.toString(),
|
|
|
|
|
// ),
|
|
|
|
|
// );
|
|
|
|
|
// Pangea#
|
|
|
|
|
|
|
|
|
|
return FlutterHiveCollectionsDatabase.databaseBuilder(client);
|
|
|
|
|
}
|
|
|
|
|
|