更新时检测webDav书籍是否比本地新,自动重新下载

pull/2380/head
kunfei 2 years ago
parent c860f26fdf
commit ae39ec6051
  1. 3
      app/src/main/java/io/legado/app/model/localBook/LocalBook.kt
  2. 2
      app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt
  3. 6
      app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt

@ -319,8 +319,7 @@ object LocalBook {
}
}
return uri?.let {
localBook.bookUrl = if (it.isContentScheme()) it.toString()
else it.path!!
localBook.bookUrl = if (it.isContentScheme()) it.toString() else it.path!!
localBook.save()
it.inputStream(appCtx)
}

@ -212,7 +212,7 @@ class BookInfoActivity :
try {
RemoteBookWebDav.upload(it)
//更新书籍最后更新时间,使之比远程书籍的时间新
it.latestChapterTime = System.currentTimeMillis()
it.lastCheckTime = System.currentTimeMillis()
viewModel.saveBook(it)
} catch (e: Exception) {
toastOnUi(e.localizedMessage)

@ -8,6 +8,7 @@ import io.legado.app.R
import io.legado.app.base.BaseViewModel
import io.legado.app.constant.AppLog
import io.legado.app.constant.BookSourceType
import io.legado.app.constant.BookType
import io.legado.app.constant.EventBus
import io.legado.app.data.appDb
import io.legado.app.data.entities.Book
@ -116,8 +117,9 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) {
book.getRemoteUrl()?.let {
val remoteBook = RemoteBookWebDav.getRemoteBook(it)
if (remoteBook == null) {
} else if (remoteBook.lastModify > book.latestChapterTime) {
book.origin = BookType.localTag
} else if (remoteBook.lastModify > book.lastCheckTime) {
val uri = RemoteBookWebDav.downloadRemoteBook(remoteBook)
}
}

Loading…
Cancel
Save