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.lang.UnsupportedOperationException
|
||||
import java.net.URLEncoder
|
||||
import java.nio.charset.StandardCharsets
|
||||
import java.text.DateFormat
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
|
@ -156,8 +155,7 @@ fun ContextWrapper.log(
|
|||
fun ContextWrapper.getLastExceptionLog(): String? {
|
||||
val logFile = getLogFile()
|
||||
if (logFile.exists()) {
|
||||
val logContents = logFile.readText().substringAfterLast("[Start]")
|
||||
return URLEncoder.encode(logContents, StandardCharsets.UTF_8.toString())
|
||||
return logFile.readText().substringAfterLast("[Start]")
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
@ -185,12 +183,12 @@ fun Context.logToFile(
|
|||
stackTrace?.let { Log.e(tag, "Exception occurred: $it") }
|
||||
|
||||
val logFile =
|
||||
folder.findFile("$fileName.txt").let {
|
||||
folder.findFile(fileName).let {
|
||||
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)) {
|
||||
it.delete()
|
||||
folder.createFile("text/plain", fileName)
|
||||
folder.createFile("text/plain", fileName.removeSuffix(".txt"))
|
||||
} else it
|
||||
}
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ fun Context.getExportedPath() = getEmptyFolder("exported")
|
|||
|
||||
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 {
|
||||
return File(getLogsDir(), APP_LOG_FILE_NAME)
|
||||
|
|
|
@ -177,14 +177,11 @@ suspend fun ContextWrapper.importZip(
|
|||
showToast(message)
|
||||
} catch (e: ZipException) {
|
||||
if (e.type == ZipException.Type.WRONG_PASSWORD) {
|
||||
log(TAG, throwable = e)
|
||||
showToast(R.string.wrong_password)
|
||||
} else {
|
||||
log(TAG, throwable = e)
|
||||
showToast(R.string.invalid_backup)
|
||||
throw e
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
showToast(R.string.invalid_backup)
|
||||
log(TAG, throwable = e)
|
||||
} finally {
|
||||
importingBackup?.value = ImportProgress(inProgress = false)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue