Skip to content

Commit

Permalink
Merge pull request #1976 from famedly/krille/use-correct-file-size-ca…
Browse files Browse the repository at this point in the history
…lculation

fix: Use MB and KB instead of MiB and KiB for file sizes
  • Loading branch information
krille-chan authored Dec 18, 2024
2 parents c39cc71 + e33a32e commit 258ca37
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/src/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3950,9 +3950,9 @@ class FileTooBigMatrixException extends MatrixException {
int maxFileSize;

static String _formatFileSize(int size) {
if (size < 1024) return '$size B';
final i = (log(size) / log(1024)).floor();
final num = (size / pow(1024, i));
if (size < 1000) return '$size B';
final i = (log(size) / log(1000)).floor();
final num = (size / pow(1000, i));
final round = num.round();
final numString = round < 10
? num.toStringAsFixed(2)
Expand Down
2 changes: 1 addition & 1 deletion lib/src/database/database_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import 'package:matrix/matrix.dart';
import 'package:matrix/src/utils/queued_to_device_event.dart';

abstract class DatabaseApi {
int get maxFileSize => 1 * 1024 * 1024;
int get maxFileSize => 1 * 1000 * 1000;

bool get supportsFileStoring => false;

Expand Down
2 changes: 1 addition & 1 deletion test/database_api_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ void main() {
);
});
test('Database can write and read 5MB data', () async {
final hugeDataObject = {'foo': createLargeString('A', 5 * 1024 * 1024)};
final hugeDataObject = {'foo': createLargeString('A', 5 * 1000 * 1000)};

await database.storeAccountData(
'm.huge_data_test',
Expand Down

0 comments on commit 258ca37

Please sign in to comment.