mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-08-14 17:57:08 +02:00
91 lines
3.6 KiB
Diff
91 lines
3.6 KiB
Diff
From 1026d4c721546ff88a725a1605350e1d14aaef36 Mon Sep 17 00:00:00 2001
|
|
From: The one with the braid <info@braid.business>
|
|
Date: Wed, 10 Apr 2024 18:07:46 +0200
|
|
Subject: [PATCH] fix: migrate back to Hive on Linux
|
|
|
|
Signed-off-by: The one with the braid <info@braid.business>
|
|
---
|
|
lib/utils/client_manager.dart | 7 +++-
|
|
.../builder.dart | 34 +++++++++++++------
|
|
2 files changed, 30 insertions(+), 11 deletions(-)
|
|
|
|
diff --git a/lib/utils/client_manager.dart b/lib/utils/client_manager.dart
|
|
index f798e8737..155cd48ed 100644
|
|
--- a/lib/utils/client_manager.dart
|
|
+++ b/lib/utils/client_manager.dart
|
|
@@ -22,6 +22,7 @@ import 'matrix_sdk_extensions/flutter_matrix_dart_sdk_database/builder.dart';
|
|
|
|
abstract class ClientManager {
|
|
static const String clientNamespace = 'im.fluffychat.store.clients';
|
|
+
|
|
static Future<List<Client>> getClients({
|
|
bool initialize = true,
|
|
required SharedPreferences store,
|
|
@@ -113,7 +114,11 @@ abstract class ClientManager {
|
|
},
|
|
logLevel: kReleaseMode ? Level.warning : Level.verbose,
|
|
databaseBuilder: flutterMatrixSdkDatabaseBuilder,
|
|
- legacyDatabaseBuilder: FlutterHiveCollectionsDatabase.databaseBuilder,
|
|
+ // workaround : migrate back from SQLite to Hive on Linux
|
|
+ // Related : https://github.com/krille-chan/fluffychat/issues/972
|
|
+ legacyDatabaseBuilder: PlatformInfos.isLinux
|
|
+ ? (client) => flutterMatrixSdkDatabaseBuilder(client, isLegacy: true)
|
|
+ : FlutterHiveCollectionsDatabase.databaseBuilder,
|
|
supportedLoginTypes: {
|
|
AuthenticationTypes.password,
|
|
AuthenticationTypes.sso,
|
|
diff --git a/lib/utils/matrix_sdk_extensions/flutter_matrix_dart_sdk_database/builder.dart b/lib/utils/matrix_sdk_extensions/flutter_matrix_dart_sdk_database/builder.dart
|
|
index 301d0c6ee..55d7fbedc 100644
|
|
--- a/lib/utils/matrix_sdk_extensions/flutter_matrix_dart_sdk_database/builder.dart
|
|
+++ b/lib/utils/matrix_sdk_extensions/flutter_matrix_dart_sdk_database/builder.dart
|
|
@@ -18,9 +18,15 @@ import 'cipher.dart';
|
|
import 'sqlcipher_stub.dart'
|
|
if (dart.library.io) 'package:sqlcipher_flutter_libs/sqlcipher_flutter_libs.dart';
|
|
|
|
-Future<DatabaseApi> flutterMatrixSdkDatabaseBuilder(Client client) async {
|
|
+Future<DatabaseApi> flutterMatrixSdkDatabaseBuilder(
|
|
+ Client client, {
|
|
+ bool isLegacy = false,
|
|
+}) async {
|
|
MatrixSdkDatabase? database;
|
|
try {
|
|
+ // unless it's the migration builder, always fall back onto Hive on Linux
|
|
+ if (PlatformInfos.isLinux && !isLegacy) throw UnimplementedError();
|
|
+
|
|
database = await _constructDatabase(client);
|
|
await database.open();
|
|
return database;
|
|
@@ -34,15 +40,23 @@ Future<DatabaseApi> flutterMatrixSdkDatabaseBuilder(Client client) async {
|
|
),
|
|
);
|
|
|
|
- // Send error notification:
|
|
- final l10n = lookupL10n(PlatformDispatcher.instance.locale);
|
|
- ClientManager.sendInitNotification(
|
|
- l10n.initAppError,
|
|
- l10n.databaseBuildErrorBody(
|
|
- AppConfig.newIssueUrl.toString(),
|
|
- e.toString(),
|
|
- ),
|
|
- );
|
|
+ final bool hideErrorMessage = PlatformInfos.isLinux;
|
|
+ if (!hideErrorMessage) {
|
|
+ // Send error notification:
|
|
+ final l10n = lookupL10n(PlatformDispatcher.instance.locale);
|
|
+ ClientManager.sendInitNotification(
|
|
+ l10n.initAppError,
|
|
+ l10n.databaseBuildErrorBody(
|
|
+ AppConfig.newIssueUrl.toString(),
|
|
+ e.toString(),
|
|
+ ),
|
|
+ );
|
|
+ } else {
|
|
+ Logs().w(
|
|
+ 'Linux database error using SQfLite. Due to many issues in this implementation, falling back to Hive.',
|
|
+ e,
|
|
+ );
|
|
+ }
|
|
|
|
return FlutterHiveCollectionsDatabase.databaseBuilder(client);
|
|
}
|