From 57d1df4fe57584bd69a8eaaabd8a14796cc99bf0 Mon Sep 17 00:00:00 2001 From: Jason Yao Date: Sun, 29 Aug 2021 18:48:59 -0400 Subject: [PATCH] restore bookSource fix --- app/src/main/java/io/legado/app/help/storage/ImportOldData.kt | 2 +- app/src/main/java/io/legado/app/help/storage/Restore.kt | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/help/storage/ImportOldData.kt b/app/src/main/java/io/legado/app/help/storage/ImportOldData.kt index e27eaf708..0e62ca68f 100644 --- a/app/src/main/java/io/legado/app/help/storage/ImportOldData.kt +++ b/app/src/main/java/io/legado/app/help/storage/ImportOldData.kt @@ -92,7 +92,7 @@ object ImportOldData { return books.size } - private fun importOldSource(json: String): Int { + fun importOldSource(json: String): Int { val bookSources = mutableListOf() val items: List> = Restore.jsonPath.parse(json).read("$") for (item in items) { diff --git a/app/src/main/java/io/legado/app/help/storage/Restore.kt b/app/src/main/java/io/legado/app/help/storage/Restore.kt index 2d797472b..7b0777ee3 100644 --- a/app/src/main/java/io/legado/app/help/storage/Restore.kt +++ b/app/src/main/java/io/legado/app/help/storage/Restore.kt @@ -125,6 +125,10 @@ object Restore { } fileToListT(path, "bookSource.json")?.let { appDb.bookSourceDao.insert(*it.toTypedArray()) + } ?: run { + val bookSourceFile = FileUtils.createFileIfNotExist(path + File.separator + "bookSource.json") + val json = bookSourceFile.readText() + ImportOldData.importOldSource(json) } fileToListT(path, "rssSources.json")?.let { appDb.rssSourceDao.insert(*it.toTypedArray())