mirror of
https://github.com/PhilKes/NotallyX.git
synced 2025-06-28 12:19:55 +00:00
Fix double encoded stacktrace on report bug
This commit is contained in:
parent
ade08b52ed
commit
23d678c8a3
3 changed files with 7 additions and 12 deletions
|
@ -45,7 +45,6 @@ import java.io.OutputStreamWriter
|
||||||
import java.io.PrintWriter
|
import java.io.PrintWriter
|
||||||
import java.lang.UnsupportedOperationException
|
import java.lang.UnsupportedOperationException
|
||||||
import java.net.URLEncoder
|
import java.net.URLEncoder
|
||||||
import java.nio.charset.StandardCharsets
|
|
||||||
import java.text.DateFormat
|
import java.text.DateFormat
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
|
@ -156,8 +155,7 @@ fun ContextWrapper.log(
|
||||||
fun ContextWrapper.getLastExceptionLog(): String? {
|
fun ContextWrapper.getLastExceptionLog(): String? {
|
||||||
val logFile = getLogFile()
|
val logFile = getLogFile()
|
||||||
if (logFile.exists()) {
|
if (logFile.exists()) {
|
||||||
val logContents = logFile.readText().substringAfterLast("[Start]")
|
return logFile.readText().substringAfterLast("[Start]")
|
||||||
return URLEncoder.encode(logContents, StandardCharsets.UTF_8.toString())
|
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
@ -185,12 +183,12 @@ fun Context.logToFile(
|
||||||
stackTrace?.let { Log.e(tag, "Exception occurred: $it") }
|
stackTrace?.let { Log.e(tag, "Exception occurred: $it") }
|
||||||
|
|
||||||
val logFile =
|
val logFile =
|
||||||
folder.findFile("$fileName.txt").let {
|
folder.findFile(fileName).let {
|
||||||
if (it == null || !it.exists()) {
|
if (it == null || !it.exists()) {
|
||||||
folder.createFile("text/plain", fileName)
|
folder.createFile("text/plain", fileName.removeSuffix(".txt"))
|
||||||
} else if (it.isLargerThanKb(MAX_LOGS_FILE_SIZE_KB)) {
|
} else if (it.isLargerThanKb(MAX_LOGS_FILE_SIZE_KB)) {
|
||||||
it.delete()
|
it.delete()
|
||||||
folder.createFile("text/plain", fileName)
|
folder.createFile("text/plain", fileName.removeSuffix(".txt"))
|
||||||
} else it
|
} else it
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -149,7 +149,7 @@ fun Context.getExportedPath() = getEmptyFolder("exported")
|
||||||
|
|
||||||
fun ContextWrapper.getLogsDir() = File(filesDir, "logs").also { it.mkdir() }
|
fun ContextWrapper.getLogsDir() = File(filesDir, "logs").also { it.mkdir() }
|
||||||
|
|
||||||
const val APP_LOG_FILE_NAME = "Log.v1.txt"
|
const val APP_LOG_FILE_NAME = "notallyx-logs.txt"
|
||||||
|
|
||||||
fun ContextWrapper.getLogFile(): File {
|
fun ContextWrapper.getLogFile(): File {
|
||||||
return File(getLogsDir(), APP_LOG_FILE_NAME)
|
return File(getLogsDir(), APP_LOG_FILE_NAME)
|
||||||
|
|
|
@ -177,14 +177,11 @@ suspend fun ContextWrapper.importZip(
|
||||||
showToast(message)
|
showToast(message)
|
||||||
} catch (e: ZipException) {
|
} catch (e: ZipException) {
|
||||||
if (e.type == ZipException.Type.WRONG_PASSWORD) {
|
if (e.type == ZipException.Type.WRONG_PASSWORD) {
|
||||||
|
log(TAG, throwable = e)
|
||||||
showToast(R.string.wrong_password)
|
showToast(R.string.wrong_password)
|
||||||
} else {
|
} else {
|
||||||
log(TAG, throwable = e)
|
throw e
|
||||||
showToast(R.string.invalid_backup)
|
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
|
||||||
showToast(R.string.invalid_backup)
|
|
||||||
log(TAG, throwable = e)
|
|
||||||
} finally {
|
} finally {
|
||||||
importingBackup?.value = ImportProgress(inProgress = false)
|
importingBackup?.value = ImportProgress(inProgress = false)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue