pull/1732/head
kunfei 3 years ago
parent dec5d386bc
commit cf0a00a712
  1. 13
      app/src/main/java/io/legado/app/help/storage/AppWebDav.kt

@ -122,8 +122,11 @@ object AppWebDav {
} }
suspend fun hasBackUp(): Boolean { suspend fun hasBackUp(): Boolean {
val url = "${rootWebDavUrl}${backupFileName}" if (isOk) {
return WebDav(url).exists() val url = "${rootWebDavUrl}${backupFileName}"
return WebDav(url).exists()
}
return false
} }
suspend fun backUpWebDav(path: String) { suspend fun backUpWebDav(path: String) {
@ -163,15 +166,14 @@ object AppWebDav {
} }
fun uploadBookProgress(book: Book) { fun uploadBookProgress(book: Book) {
if (!isOk) return
if (!AppConfig.syncBookProgress) return if (!AppConfig.syncBookProgress) return
if (!NetworkUtils.isAvailable()) return if (!NetworkUtils.isAvailable()) return
Coroutine.async { Coroutine.async {
val bookProgress = BookProgress(book) val bookProgress = BookProgress(book)
val json = GSON.toJson(bookProgress) val json = GSON.toJson(bookProgress)
val url = getProgressUrl(book) val url = getProgressUrl(book)
if (isOk) { WebDav(url).upload(json.toByteArray(), "application/json")
WebDav(url).upload(json.toByteArray(), "application/json")
}
} }
} }
@ -196,6 +198,7 @@ object AppWebDav {
} }
suspend fun downloadAllBookProgress() { suspend fun downloadAllBookProgress() {
if (!isOk) return
appDb.bookDao.all.forEach { book -> appDb.bookDao.all.forEach { book ->
getBookProgress(book)?.let { bookProgress -> getBookProgress(book)?.let { bookProgress ->
if (bookProgress.durChapterIndex > book.durChapterIndex || if (bookProgress.durChapterIndex > book.durChapterIndex ||

Loading…
Cancel
Save