Ensure that log files are not too big, else the rageshake server will reject the request.
See https://github.com/element-hq/element-android/issues/9096#issuecomment-3480128082 Closes #5983
This commit is contained in:
@@ -25,4 +25,9 @@ object RageshakeConfig {
|
||||
* The maximum size of the upload request. Default value is just below CloudFlare's max request size.
|
||||
*/
|
||||
const val MAX_LOG_UPLOAD_SIZE = 50 * 1024 * 1024L
|
||||
|
||||
/**
|
||||
* The maximum size of a single log file.
|
||||
*/
|
||||
const val MAX_LOG_CONTENT_SIZE = 100 * 1024 * 1024L
|
||||
}
|
||||
|
||||
@@ -158,6 +158,7 @@ class DefaultBugReporter(
|
||||
}
|
||||
if (withCrashLogs || withDevicesLogs) {
|
||||
saveLogCat()
|
||||
?.takeIf { it.length() < RageshakeConfig.MAX_LOG_CONTENT_SIZE }
|
||||
?.let { logCatFile ->
|
||||
compressFile(logCatFile).also {
|
||||
logCatFile.safeDelete()
|
||||
@@ -191,6 +192,7 @@ class DefaultBugReporter(
|
||||
.addFormDataPart("label", buildMeta.versionName)
|
||||
.addFormDataPart("label", buildMeta.flavorDescription)
|
||||
.addFormDataPart("branch_name", buildMeta.gitBranchName)
|
||||
|
||||
userId?.let {
|
||||
matrixClientProvider.getOrNull(it)?.let { client ->
|
||||
val curveKey = client.encryptionService.deviceCurve25519()
|
||||
@@ -390,7 +392,11 @@ class DefaultBugReporter(
|
||||
) {
|
||||
val logDirectory = logDirectory()
|
||||
logDirectory.listFiles()
|
||||
?.filter { it.isFile && !it.name.endsWith(LOG_CAT_FILENAME) }
|
||||
?.filter {
|
||||
it.isFile &&
|
||||
!it.name.endsWith(LOG_CAT_FILENAME) &&
|
||||
it.length() < RageshakeConfig.MAX_LOG_CONTENT_SIZE
|
||||
}
|
||||
}.orEmpty()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user