pull/1835/head
kunfei 3 years ago
parent fabb74990a
commit dfbeb3797b
  1. 2
      app/src/main/java/io/legado/app/help/storage/AppWebDav.kt
  2. 5
      app/src/main/java/io/legado/app/lib/webdav/WebDav.kt
  3. 5
      app/src/main/java/io/legado/app/lib/webdav/WebDavFile.kt
  4. 2
      app/src/main/java/io/legado/app/ui/main/MainActivity.kt

@ -142,7 +142,7 @@ object AppWebDav {
return kotlin.runCatching {
authorization?.let {
var lastBackupFile: WebDavFile? = null
WebDav(rootWebDavUrl, it).listFiles().forEach { webDavFile ->
WebDav(rootWebDavUrl, it).listFiles().reversed().forEach { webDavFile ->
if (webDavFile.displayName.startsWith("backup")) {
if (lastBackupFile == null
|| webDavFile.lastModify > lastBackupFile!!.lastModify

@ -20,7 +20,6 @@ import java.net.MalformedURLException
import java.net.URL
import java.net.URLEncoder
import java.text.SimpleDateFormat
import java.util.*
@Suppress("unused", "MemberVisibilityCanBePrivate")
open class WebDav(urlStr: String, val authorization: Authorization) {
@ -133,12 +132,12 @@ open class WebDav(urlStr: String, val authorization: Authorization) {
element.getElementsByTag("d:getcontentlength")
.firstOrNull()?.text()?.toLong() ?: 0
}.getOrDefault(0)
val lastModify: Date? = kotlin.runCatching {
val lastModify: Long = kotlin.runCatching {
element.getElementsByTag("d:getcontentlength")
.firstOrNull()?.text()?.let {
dateFormat.parse(it)
}
}.getOrNull()
}.getOrNull()?.time ?: 0
webDavFile = WebDavFile(
baseUrl + fileName,
authorization,

@ -1,10 +1,9 @@
package io.legado.app.lib.webdav
import java.util.*
/**
* webDavFile
*/
@Suppress("unused")
class WebDavFile(
urlStr: String,
authorization: Authorization,
@ -12,5 +11,5 @@ class WebDavFile(
val urlName: String,
val size: Long,
val contentType: String,
val lastModify: Date?
val lastModify: Long
) : WebDav(urlStr, authorization)

@ -97,7 +97,7 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
launch {
val lastBackupFile = withContext(IO) { AppWebDav.lastBackUp().getOrNull() }
?: return@launch
if (lastBackupFile.lastModify?.time ?: 0 - LocalConfig.lastBackup > DateUtils.MINUTE_IN_MILLIS) {
if (lastBackupFile.lastModify - LocalConfig.lastBackup > DateUtils.MINUTE_IN_MILLIS) {
alert("恢复", "webDav书源比本地新,是否恢复") {
cancelButton()
okButton {

Loading…
Cancel
Save