fix: fix the issue that user avatar can not be loaded on windows
chore: resort imports
This commit is contained in:
parent
026fd74352
commit
f98f93c1ed
|
|
@ -1,6 +1,8 @@
|
|||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:path/path.dart';
|
||||
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
mixin DatabaseFileStorage {
|
||||
|
|
@ -9,9 +11,19 @@ mixin DatabaseFileStorage {
|
|||
late final Uri? fileStorageLocation;
|
||||
late final Duration? deleteFilesAfterDuration;
|
||||
|
||||
File _getFileFromMxc(Uri mxcUri) => File(
|
||||
'${Directory.fromUri(fileStorageLocation!).path}/${mxcUri.toString().split('/').last}',
|
||||
/// Map an MXC URI to a local File path
|
||||
File _getFileFromMxc(Uri mxcUri) {
|
||||
// Replace all special characters with underscores to avoid PathNotFoundException on Windows.
|
||||
final host = mxcUri.host.replaceAll('.', '_');
|
||||
final path = mxcUri.pathSegments.join('_');
|
||||
final query = mxcUri.queryParameters.entries
|
||||
.map((entry) => '${entry.key}${entry.value}')
|
||||
.join('_');
|
||||
final fileName = '${host}_${path}_$query';
|
||||
return File(
|
||||
join(Directory.fromUri(fileStorageLocation!).path, fileName),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> storeFile(Uri mxcUri, Uint8List bytes, int time) async {
|
||||
final fileStorageLocation = this.fileStorageLocation;
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ dependencies:
|
|||
js: ^0.6.3
|
||||
markdown: ^7.1.1
|
||||
mime: ">=1.0.0 <3.0.0"
|
||||
path: ^1.9.1
|
||||
random_string: ^2.3.1
|
||||
sdp_transform: ^0.3.2
|
||||
slugify: ^2.0.0
|
||||
|
|
@ -39,6 +40,5 @@ dev_dependencies:
|
|||
file: ">=6.1.1 <8.0.0"
|
||||
import_sorter: ^4.6.0
|
||||
lints: ^5.0.0
|
||||
path: ^1.9.1
|
||||
sqflite_common_ffi: ^2.3.4+4 # sqflite_common_ffi aggressively requires newer dart versions
|
||||
test: ^1.25.13
|
||||
|
|
|
|||
Loading…
Reference in New Issue