Skip to content

Commit

Permalink
fix: 方案选择失败时重置配置文件
Browse files Browse the repository at this point in the history
#454 修改后,存在用户在修改方案过程中误删 default.custom.yaml 场景。方案列表检查为空时进行一次配置文件重置,避免default.custom导致的方案部署问题
  • Loading branch information
DND163 committed Aug 26, 2021
1 parent 7cc3eca commit 802a851
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Expand Up @@ -10,6 +10,7 @@ import com.osfans.trime.R
import com.osfans.trime.Rime
import com.osfans.trime.ime.core.Trime
import com.osfans.trime.settings.PrefMainActivity
import com.osfans.trime.setup.Config
import com.osfans.trime.util.RimeUtils
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
Expand Down Expand Up @@ -122,7 +123,12 @@ class SchemaPickerDialog(
}

private fun initSchemas() {
if (schemaMapList.isNullOrEmpty()) return
if (schemaMapList.isNullOrEmpty()) {
// 尝试一次配置文件重置 缺失 default.custom.yaml 导致方案为空
Config.get(context).prepareRime(context)
schemaMapList = Rime.get_available_schema_list()
if (schemaMapList.isNullOrEmpty()) return
}
schemaMapList!!.sortedWith(SortByName())
val selectedSchemas = Rime.get_selected_schema_list()
val selectedIds = ArrayList<String>()
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/osfans/trime/setup/Config.java
Expand Up @@ -160,7 +160,7 @@ public String getResDataDir(String sub) {
return new File(getUserDataDir(), sub).getPath();
}

private void prepareRime(Context context) {
public void prepareRime(Context context) {
boolean isExist = new File(getSharedDataDir()).exists();
boolean isOverwrite = AppVersionUtils.INSTANCE.isDifferentVersion(getPrefs());
String defaultFile = "trime.yaml";
Expand Down

0 comments on commit 802a851

Please sign in to comment.