From f5da400a059b4f01808dfc0460eeb9f3ec221360 Mon Sep 17 00:00:00 2001 From: Sorunome Date: Thu, 24 Jun 2021 14:13:35 +0200 Subject: [PATCH] fix: Database does not store files correctly --- lib/utils/database/flutter_famedly_sdk_hive_database.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/utils/database/flutter_famedly_sdk_hive_database.dart b/lib/utils/database/flutter_famedly_sdk_hive_database.dart index cfb126780..5926ca394 100644 --- a/lib/utils/database/flutter_famedly_sdk_hive_database.dart +++ b/lib/utils/database/flutter_famedly_sdk_hive_database.dart @@ -50,7 +50,7 @@ class FlutterFamedlySdkHiveDatabase extends FamedlySdkHiveDatabase { } on MissingPluginException catch (_) { Logs().i('Hive encryption is not supported on this platform'); } - final db = FamedlySdkHiveDatabase( + final db = FlutterFamedlySdkHiveDatabase( client.clientName, encryptionCipher: hiverCipher, ); @@ -78,7 +78,7 @@ class FlutterFamedlySdkHiveDatabase extends FamedlySdkHiveDatabase { Future getFile(String mxcUri) async { if (!supportsFileStoring) return null; final tempDirectory = await _getFileStoreDirectory(); - final file = File('$tempDirectory/$mxcUri'); + final file = File('$tempDirectory/${Uri.encodeComponent(mxcUri)}'); if (await file.exists() == false) return null; final bytes = await file.readAsBytes(); return bytes; @@ -88,7 +88,7 @@ class FlutterFamedlySdkHiveDatabase extends FamedlySdkHiveDatabase { Future storeFile(String mxcUri, Uint8List bytes, int time) async { if (!supportsFileStoring) return null; final tempDirectory = await _getFileStoreDirectory(); - final file = File('$tempDirectory/$mxcUri'); + final file = File('$tempDirectory/${Uri.encodeComponent(mxcUri)}'); if (await file.exists()) return; await file.writeAsBytes(bytes); return;