Merge pull request #1284 from h11128/restore_booksource_fix

解决无法备份恢复旧版书源的问题
pull/1295/head
kunfei 3 years ago committed by GitHub
commit 595cd99dc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/src/main/java/io/legado/app/help/storage/ImportOldData.kt
  2. 4
      app/src/main/java/io/legado/app/help/storage/Restore.kt

@ -92,7 +92,7 @@ object ImportOldData {
return books.size return books.size
} }
private fun importOldSource(json: String): Int { fun importOldSource(json: String): Int {
val bookSources = mutableListOf<BookSource>() val bookSources = mutableListOf<BookSource>()
val items: List<Map<String, Any>> = Restore.jsonPath.parse(json).read("$") val items: List<Map<String, Any>> = Restore.jsonPath.parse(json).read("$")
for (item in items) { for (item in items) {

@ -125,6 +125,10 @@ object Restore {
} }
fileToListT<BookSource>(path, "bookSource.json")?.let { fileToListT<BookSource>(path, "bookSource.json")?.let {
appDb.bookSourceDao.insert(*it.toTypedArray()) appDb.bookSourceDao.insert(*it.toTypedArray())
} ?: run {
val bookSourceFile = FileUtils.createFileIfNotExist(path + File.separator + "bookSource.json")
val json = bookSourceFile.readText()
ImportOldData.importOldSource(json)
} }
fileToListT<RssSource>(path, "rssSources.json")?.let { fileToListT<RssSource>(path, "rssSources.json")?.let {
appDb.rssSourceDao.insert(*it.toTypedArray()) appDb.rssSourceDao.insert(*it.toTypedArray())

Loading…
Cancel
Save