@@ -3,6 +3,7 @@ package li.songe.gkd.util
33import android.text.format.DateUtils
44import androidx.annotation.WorkerThread
55import kotlinx.serialization.Serializable
6+ import kotlinx.serialization.json.Json
67import li.songe.gkd.META
78import li.songe.gkd.app
89import li.songe.gkd.data.AppInfo
@@ -21,7 +22,15 @@ fun File.autoMk(): File {
2122}
2223
2324private val filesDir: File by lazy {
24- app.getExternalFilesDir(null ) ? : error(" failed getExternalFilesDir" )
25+ val markFile = app.filesDir.resolve(" .gkd" )
26+ if (markFile.isFile) {
27+ app.filesDir
28+ } else {
29+ // fix #1333
30+ app.getExternalFilesDir(null ) ? : app.filesDir.also {
31+ markFile.createNewFile()
32+ }
33+ }
2534}
2635
2736val dbFolder: File
@@ -42,7 +51,7 @@ val crashTempFolder: File
4251 get() = filesDir.resolve(" crash/temp" ).autoMk()
4352
4453val privateStoreFolder: File
45- get() = app.filesDir.resolve(" store" ).autoMk()
54+ get() = app.filesDir.resolve(" private- store" ).autoMk()
4655
4756private val cacheDir by lazy { app.externalCacheDir ? : app.cacheDir }
4857val coilCacheDir: File
@@ -87,10 +96,6 @@ private data class AppJsonData(
8796fun buildLogFile (): File {
8897 val tempDir = createGkdTempDir()
8998 val files = mutableListOf (dbFolder, storeFolder, subsFolder, logFolder, crashFolder)
90- tempDir.resolve(" meta.json" ).also {
91- it.writeText(toJson5String(META ))
92- files.add(it)
93- }
9499 tempDir.resolve(" apps.json" ).also {
95100 it.writeText(json.encodeToString(AppJsonData ()))
96101 files.add(it)
@@ -108,8 +113,11 @@ fun buildLogFile(): File {
108113 it.appendText(" \n appListAuthAbnormalFlow: ${appListAuthAbnormalFlow.value} " )
109114 files.add(it)
110115 }
116+ val formattedJson = Json (from = json) {
117+ prettyPrint = true
118+ }
111119 tempDir.resolve(" gkd-${META .versionCode} -v${META .versionName} .json" ).also {
112- it.writeText(json .encodeToString(META ))
120+ it.writeText(formattedJson .encodeToString(META ))
113121 files.add(it)
114122 }
115123 val logZipFile = sharedDir.resolve(" log-${System .currentTimeMillis()} .zip" )
0 commit comments