优化
This commit is contained in:
@@ -105,21 +105,14 @@ object Restore {
|
||||
.forEach { book ->
|
||||
book.coverUrl = LocalBook.getCoverPath(book)
|
||||
}
|
||||
val updateBooks = arrayListOf<Book>()
|
||||
val newBooks = arrayListOf<Book>()
|
||||
val ignoreLocalBook = BackupConfig.ignoreLocalBook
|
||||
it.forEach { book ->
|
||||
if (ignoreLocalBook && book.isLocal) {
|
||||
return@forEach
|
||||
}
|
||||
if (appDb.bookDao.has(book.bookUrl)) {
|
||||
updateBooks.add(book)
|
||||
} else {
|
||||
newBooks.add(book)
|
||||
val books = if (BackupConfig.ignoreLocalBook) {
|
||||
it.filter { book ->
|
||||
!book.isLocal
|
||||
}
|
||||
} else {
|
||||
it
|
||||
}
|
||||
appDb.bookDao.update(*updateBooks.toTypedArray())
|
||||
appDb.bookDao.insert(*newBooks.toTypedArray())
|
||||
appDb.bookDao.insert(*books.toTypedArray())
|
||||
}
|
||||
fileToListT<Bookmark>(path, "bookmark.json")?.let {
|
||||
appDb.bookmarkDao.insert(*it.toTypedArray())
|
||||
|
||||
Reference in New Issue
Block a user