From 580622da9a4ec173789c675a11ec4f7ee09ccae5 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 13 Jun 2024 17:43:45 +0200 Subject: [PATCH] Move MAX_LOG_UPLOAD_SIZE to RageshakeConfig --- .../kotlin/io/element/android/appconfig/ApplicationConfig.kt | 5 ----- .../kotlin/io/element/android/appconfig/RageshakeConfig.kt | 4 ++++ .../features/rageshake/impl/reporter/DefaultBugReporter.kt | 5 ++--- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/appconfig/src/main/kotlin/io/element/android/appconfig/ApplicationConfig.kt b/appconfig/src/main/kotlin/io/element/android/appconfig/ApplicationConfig.kt index e8a8a2b33a..21af158ad6 100644 --- a/appconfig/src/main/kotlin/io/element/android/appconfig/ApplicationConfig.kt +++ b/appconfig/src/main/kotlin/io/element/android/appconfig/ApplicationConfig.kt @@ -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 } diff --git a/appconfig/src/main/kotlin/io/element/android/appconfig/RageshakeConfig.kt b/appconfig/src/main/kotlin/io/element/android/appconfig/RageshakeConfig.kt index c44f64e43d..9fd9dce578 100644 --- a/appconfig/src/main/kotlin/io/element/android/appconfig/RageshakeConfig.kt +++ b/appconfig/src/main/kotlin/io/element/android/appconfig/RageshakeConfig.kt @@ -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 } diff --git a/features/rageshake/impl/src/main/kotlin/io/element/android/features/rageshake/impl/reporter/DefaultBugReporter.kt b/features/rageshake/impl/src/main/kotlin/io/element/android/features/rageshake/impl/reporter/DefaultBugReporter.kt index 930f12d343..9e89ff9a76 100755 --- a/features/rageshake/impl/src/main/kotlin/io/element/android/features/rageshake/impl/reporter/DefaultBugReporter.kt +++ b/features/rageshake/impl/src/main/kotlin/io/element/android/features/rageshake/impl/reporter/DefaultBugReporter.kt @@ -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)