优化
This commit is contained in:
@@ -127,8 +127,7 @@ object Restore {
|
|||||||
suspend fun restoreConfig(path: String = Backup.backupPath) {
|
suspend fun restoreConfig(path: String = Backup.backupPath) {
|
||||||
withContext(IO) {
|
withContext(IO) {
|
||||||
try {
|
try {
|
||||||
val file =
|
val file = File(path, DirectLinkUpload.ruleFileName)
|
||||||
FileUtils.createFileIfNotExist("$path${File.separator}${DirectLinkUpload.ruleFileName}")
|
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
val json = file.readText()
|
val json = file.readText()
|
||||||
ACache.get(cacheDir = false).put(DirectLinkUpload.ruleFileName, json)
|
ACache.get(cacheDir = false).put(DirectLinkUpload.ruleFileName, json)
|
||||||
@@ -137,8 +136,7 @@ object Restore {
|
|||||||
AppLog.put("直链上传出错\n${e.localizedMessage}", e)
|
AppLog.put("直链上传出错\n${e.localizedMessage}", e)
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
val file =
|
val file = File(path, ThemeConfig.configFileName)
|
||||||
FileUtils.createFileIfNotExist("$path${File.separator}${ThemeConfig.configFileName}")
|
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
FileUtils.delete(ThemeConfig.configFilePath)
|
FileUtils.delete(ThemeConfig.configFilePath)
|
||||||
file.copyTo(File(ThemeConfig.configFilePath))
|
file.copyTo(File(ThemeConfig.configFilePath))
|
||||||
@@ -150,8 +148,7 @@ object Restore {
|
|||||||
if (!BackupConfig.ignoreReadConfig) {
|
if (!BackupConfig.ignoreReadConfig) {
|
||||||
//恢复阅读界面配置
|
//恢复阅读界面配置
|
||||||
try {
|
try {
|
||||||
val file =
|
val file = File(path, ReadBookConfig.configFileName)
|
||||||
FileUtils.createFileIfNotExist("$path${File.separator}${ReadBookConfig.configFileName}")
|
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
FileUtils.delete(ReadBookConfig.configFilePath)
|
FileUtils.delete(ReadBookConfig.configFilePath)
|
||||||
file.copyTo(File(ReadBookConfig.configFilePath))
|
file.copyTo(File(ReadBookConfig.configFilePath))
|
||||||
@@ -161,8 +158,7 @@ object Restore {
|
|||||||
AppLog.put("恢复阅读界面出错\n${e.localizedMessage}", e)
|
AppLog.put("恢复阅读界面出错\n${e.localizedMessage}", e)
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
val file =
|
val file = File(path, ReadBookConfig.shareConfigFileName)
|
||||||
FileUtils.createFileIfNotExist("$path${File.separator}${ReadBookConfig.shareConfigFileName}")
|
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
FileUtils.delete(ReadBookConfig.shareConfigFilePath)
|
FileUtils.delete(ReadBookConfig.shareConfigFilePath)
|
||||||
file.copyTo(File(ReadBookConfig.shareConfigFilePath))
|
file.copyTo(File(ReadBookConfig.shareConfigFilePath))
|
||||||
@@ -207,7 +203,7 @@ object Restore {
|
|||||||
|
|
||||||
private inline fun <reified T> fileToListT(path: String, fileName: String): List<T>? {
|
private inline fun <reified T> fileToListT(path: String, fileName: String): List<T>? {
|
||||||
try {
|
try {
|
||||||
val file = File(path + File.separator + fileName)
|
val file = File(path, fileName)
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
FileInputStream(file).use {
|
FileInputStream(file).use {
|
||||||
return GSON.fromJsonArray<T>(it).getOrThrow()
|
return GSON.fromJsonArray<T>(it).getOrThrow()
|
||||||
|
|||||||
Reference in New Issue
Block a user