File tree 1 file changed +7
-7
lines changed
app/src/main/java/com/osfans/trime/data/base
1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -70,12 +70,13 @@ object DataManager {
70
70
onDataDirChangeListeners.forEach { it.onDataDirChange() }
71
71
}
72
72
73
- @JvmStatic
74
73
val sharedDataDir = File (appContext.getExternalFilesDir(null ), " shared" ).also { it.mkdirs() }
75
74
76
- @JvmStatic
77
75
val userDataDir
78
- get() = File (prefs.profile.userDataDir)
76
+ get() =
77
+ File (prefs.profile.userDataDir).also {
78
+ if (! it.exists()) it.mkdirs()
79
+ }
79
80
80
81
/* *
81
82
* Return the absolute path of the compiled config file
@@ -122,12 +123,11 @@ object DataManager {
122
123
ResourceUtils .copyFile(DATA_CHECKSUMS_NAME , dataDir)
123
124
124
125
// FIXME:缺失 default.custom.yaml 会导致方案列表为空
125
- File (userDataDir, DEFAULT_CUSTOM_FILE_NAME ). let {
126
- if (! it.exists ()) {
126
+ runCatching {
127
+ if (File (userDataDir, DEFAULT_CUSTOM_FILE_NAME ).createNewFile ()) {
127
128
Timber .d(" Creating empty default.custom.yaml" )
128
- it.bufferedWriter().use { w -> w.write(" " ) }
129
129
}
130
- }
130
+ }.getOrElse { Timber .e(it, " Failed to create default.custom.yaml " ) }
131
131
132
132
Timber .d(" Synced!" )
133
133
}
You can’t perform that action at this time.
0 commit comments