From c476e87eec743072362f94f26a120c0ff66eb2d4 Mon Sep 17 00:00:00 2001 From: Jason Elie Bou Kheir <5115126+jasonboukheir@users.noreply.github.com> Date: Sat, 17 Feb 2024 13:19:22 -0800 Subject: [PATCH] fix(android): move log zip file outside of log folder (#3677) Fixes #3330 The when the log zip file is created, it's created as an empty file in the `logs` directory. The `logs` directory is then zipped, and written to the zip file. The empty file remains as an artifact in the final zip file. This moves the location of the zip file outside of the `logs` directory, where it will be cleaned up later. --- .../android/features/settings/ui/SettingsViewModel.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kotlin/android/app/src/main/java/dev/firezone/android/features/settings/ui/SettingsViewModel.kt b/kotlin/android/app/src/main/java/dev/firezone/android/features/settings/ui/SettingsViewModel.kt index c7694c8ac..637aac0ff 100644 --- a/kotlin/android/app/src/main/java/dev/firezone/android/features/settings/ui/SettingsViewModel.kt +++ b/kotlin/android/app/src/main/java/dev/firezone/android/features/settings/ui/SettingsViewModel.kt @@ -114,7 +114,7 @@ internal class SettingsViewModel viewModelScope.launch { val logDir = context.cacheDir.absolutePath + "/logs" val sourceFolder = File(logDir) - val zipFile = File("$logDir/connlib-logs.zip") + val zipFile = File(getLogZipPath(context)) zipFolder(sourceFolder, zipFile).collect() @@ -186,13 +186,14 @@ internal class SettingsViewModel }.flowOn(Dispatchers.IO) private fun deleteLogZip(context: Context) { - val logDir = context.cacheDir.absolutePath + "/logs" - val zipFile = File("$logDir/connlib-logs.zip") + val zipFile = File(getLogZipPath(context)) if (zipFile.exists()) { zipFile.delete() } } + private fun getLogZipPath(context: Context) = "${context.cacheDir.absolutePath}/connlib-logs.zip" + private fun onFieldUpdated() { _uiState.value = _uiState.value.copy(