Use IO dispatcher for cleanup in bug reporter (#3092)

This commit is contained in:
Jorge Martin Espinosa 2024-06-25 11:26:18 +02:00 committed by GitHub
parent 924d78f3c7
commit 6def355b6e
2 changed files with 7 additions and 4 deletions

1
changelog.d/3086.bugfix Normal file
View file

@ -0,0 +1 @@
Make sure we don't use the main dispatcher while closing the bug report request, as it can lead to crashes in strict mode.

View file

@ -282,6 +282,7 @@ class DefaultBugReporter @Inject constructor(
listener.onUploadFailed(serverError) listener.onUploadFailed(serverError)
} }
} finally { } finally {
withContext(coroutineDispatchers.io) {
// delete the generated files when the bug report process has finished // delete the generated files when the bug report process has finished
for (file in bugReportFiles) { for (file in bugReportFiles) {
file.safeDelete() file.safeDelete()
@ -289,6 +290,7 @@ class DefaultBugReporter @Inject constructor(
response?.close() response?.close()
} }
} }
}
override fun logDirectory(): File { override fun logDirectory(): File {
return File(context.cacheDir, LOG_DIRECTORY_NAME).apply { return File(context.cacheDir, LOG_DIRECTORY_NAME).apply {