Move MAX_LOG_UPLOAD_SIZE to RageshakeConfig

This commit is contained in:
Benoit Marty 2024-06-13 17:43:45 +02:00 committed by Benoit Marty
parent 816d60b6ce
commit ea679cc108
3 changed files with 6 additions and 8 deletions

View file

@ -40,9 +40,4 @@ object ApplicationConfig {
* For Element, the value is "Element". We use the same name for desktop and mobile for now.
*/
const val DESKTOP_APPLICATION_NAME: String = "Element"
/**
* 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
}

View file

@ -19,4 +19,8 @@ package io.element.android.appconfig
object RageshakeConfig {
const val BUG_REPORT_URL = "https://riot.im/bugreports/submit"
const val BUG_REPORT_APP_NAME = "element-x-android"
/**
* 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
}

View file

@ -21,7 +21,6 @@ import android.os.Build
import androidx.core.net.toFile
import androidx.core.net.toUri
import com.squareup.anvil.annotations.ContributesBinding
import io.element.android.appconfig.ApplicationConfig
import io.element.android.appconfig.RageshakeConfig
import io.element.android.features.rageshake.api.crash.CrashDataStore
import io.element.android.features.rageshake.api.reporter.BugReporter
@ -178,7 +177,7 @@ class DefaultBugReporter @Inject constructor(
val requestBody = file.asRequestBody(MimeTypes.OctetStream.toMediaTypeOrNull())
totalUploadedSize += requestBody.contentLength()
// If we are about to upload more than the max request size, stop here
if (totalUploadedSize > ApplicationConfig.MAX_LOG_UPLOAD_SIZE) {
if (totalUploadedSize > RageshakeConfig.MAX_LOG_UPLOAD_SIZE) {
Timber.e("Could not upload file ${file.name} because it would exceed the max request size")
break
}
@ -375,7 +374,7 @@ class DefaultBugReporter @Inject constructor(
val separator = System.lineSeparator()
logcatProcess.inputStream
.reader()
.buffered(ApplicationConfig.MAX_LOG_UPLOAD_SIZE.toInt())
.buffered(RageshakeConfig.MAX_LOG_UPLOAD_SIZE.toInt())
.forEachLine { line ->
streamWriter.append(line)
streamWriter.append(separator)