更新时检测webDav书籍是否比本地新,自动重新下载
This commit is contained in:
@@ -319,8 +319,7 @@ object LocalBook {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return uri?.let {
|
return uri?.let {
|
||||||
localBook.bookUrl = if (it.isContentScheme()) it.toString()
|
localBook.bookUrl = if (it.isContentScheme()) it.toString() else it.path!!
|
||||||
else it.path!!
|
|
||||||
localBook.save()
|
localBook.save()
|
||||||
it.inputStream(appCtx)
|
it.inputStream(appCtx)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ class BookInfoActivity :
|
|||||||
try {
|
try {
|
||||||
RemoteBookWebDav.upload(it)
|
RemoteBookWebDav.upload(it)
|
||||||
//更新书籍最后更新时间,使之比远程书籍的时间新
|
//更新书籍最后更新时间,使之比远程书籍的时间新
|
||||||
it.latestChapterTime = System.currentTimeMillis()
|
it.lastCheckTime = System.currentTimeMillis()
|
||||||
viewModel.saveBook(it)
|
viewModel.saveBook(it)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
toastOnUi(e.localizedMessage)
|
toastOnUi(e.localizedMessage)
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import io.legado.app.R
|
|||||||
import io.legado.app.base.BaseViewModel
|
import io.legado.app.base.BaseViewModel
|
||||||
import io.legado.app.constant.AppLog
|
import io.legado.app.constant.AppLog
|
||||||
import io.legado.app.constant.BookSourceType
|
import io.legado.app.constant.BookSourceType
|
||||||
|
import io.legado.app.constant.BookType
|
||||||
import io.legado.app.constant.EventBus
|
import io.legado.app.constant.EventBus
|
||||||
import io.legado.app.data.appDb
|
import io.legado.app.data.appDb
|
||||||
import io.legado.app.data.entities.Book
|
import io.legado.app.data.entities.Book
|
||||||
@@ -116,8 +117,9 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) {
|
|||||||
book.getRemoteUrl()?.let {
|
book.getRemoteUrl()?.let {
|
||||||
val remoteBook = RemoteBookWebDav.getRemoteBook(it)
|
val remoteBook = RemoteBookWebDav.getRemoteBook(it)
|
||||||
if (remoteBook == null) {
|
if (remoteBook == null) {
|
||||||
|
book.origin = BookType.localTag
|
||||||
} else if (remoteBook.lastModify > book.latestChapterTime) {
|
} else if (remoteBook.lastModify > book.lastCheckTime) {
|
||||||
|
val uri = RemoteBookWebDav.downloadRemoteBook(remoteBook)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user