fix: Check the max server file size after shrinking not before
This commit is contained in:
parent
65828e11d9
commit
c6f7da12d4
|
|
@ -757,22 +757,6 @@ class Room {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check media config of the server before sending the file. Stop if the
|
|
||||||
// Media config is unreachable or the file is bigger than the given maxsize.
|
|
||||||
try {
|
|
||||||
final mediaConfig = await client.getConfig();
|
|
||||||
final maxMediaSize = mediaConfig.mUploadSize;
|
|
||||||
if (maxMediaSize != null && maxMediaSize < file.bytes.lengthInBytes) {
|
|
||||||
throw FileTooBigMatrixException(file.bytes.lengthInBytes, maxMediaSize);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
Logs().d('Config error while sending file', e);
|
|
||||||
syncUpdate.rooms!.join!.values.first.timeline!.events!.first
|
|
||||||
.unsigned![messageSendingStatusKey] = EventStatus.error.intValue;
|
|
||||||
await _handleFakeSync(syncUpdate);
|
|
||||||
rethrow;
|
|
||||||
}
|
|
||||||
|
|
||||||
MatrixFile uploadFile = file; // ignore: omit_local_variable_types
|
MatrixFile uploadFile = file; // ignore: omit_local_variable_types
|
||||||
// computing the thumbnail in case we can
|
// computing the thumbnail in case we can
|
||||||
if (file is MatrixImageFile &&
|
if (file is MatrixImageFile &&
|
||||||
|
|
@ -800,6 +784,22 @@ class Room {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check media config of the server before sending the file. Stop if the
|
||||||
|
// Media config is unreachable or the file is bigger than the given maxsize.
|
||||||
|
try {
|
||||||
|
final mediaConfig = await client.getConfig();
|
||||||
|
final maxMediaSize = mediaConfig.mUploadSize;
|
||||||
|
if (maxMediaSize != null && maxMediaSize < file.bytes.lengthInBytes) {
|
||||||
|
throw FileTooBigMatrixException(file.bytes.lengthInBytes, maxMediaSize);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
Logs().d('Config error while sending file', e);
|
||||||
|
syncUpdate.rooms!.join!.values.first.timeline!.events!.first
|
||||||
|
.unsigned![messageSendingStatusKey] = EventStatus.error.intValue;
|
||||||
|
await _handleFakeSync(syncUpdate);
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
|
||||||
MatrixFile? uploadThumbnail =
|
MatrixFile? uploadThumbnail =
|
||||||
thumbnail; // ignore: omit_local_variable_types
|
thumbnail; // ignore: omit_local_variable_types
|
||||||
EncryptedFile? encryptedFile;
|
EncryptedFile? encryptedFile;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue