This commit is contained in:
Horis
2025-06-13 18:16:18 +08:00
parent 02c71ca90f
commit a39d615928
@@ -105,21 +105,14 @@ object Restore {
.forEach { book -> .forEach { book ->
book.coverUrl = LocalBook.getCoverPath(book) book.coverUrl = LocalBook.getCoverPath(book)
} }
val updateBooks = arrayListOf<Book>() val books = if (BackupConfig.ignoreLocalBook) {
val newBooks = arrayListOf<Book>() it.filter { book ->
val ignoreLocalBook = BackupConfig.ignoreLocalBook !book.isLocal
it.forEach { book ->
if (ignoreLocalBook && book.isLocal) {
return@forEach
}
if (appDb.bookDao.has(book.bookUrl)) {
updateBooks.add(book)
} else {
newBooks.add(book)
} }
} else {
it
} }
appDb.bookDao.update(*updateBooks.toTypedArray()) appDb.bookDao.insert(*books.toTypedArray())
appDb.bookDao.insert(*newBooks.toTypedArray())
} }
fileToListT<Bookmark>(path, "bookmark.json")?.let { fileToListT<Bookmark>(path, "bookmark.json")?.let {
appDb.bookmarkDao.insert(*it.toTypedArray()) appDb.bookmarkDao.insert(*it.toTypedArray())