pull/1835/head
kunfei 3 years ago
parent d14f6e9bb3
commit 226acdb4c9
  1. 8
      app/src/main/java/io/legado/app/help/storage/AppWebDav.kt
  2. 3
      app/src/main/java/io/legado/app/help/storage/Backup.kt

@ -130,6 +130,14 @@ object AppWebDav {
}
}
suspend fun hasBackUp(): Boolean {
authorization?.let {
val url = "${rootWebDavUrl}${backupFileName}"
return WebDav(url, it).exists()
}
return false
}
suspend fun lastBackUp(): WebDavFile? {
authorization?.let {
var lastBackupFile: WebDavFile? = null

@ -51,8 +51,7 @@ object Backup {
val lastBackup = LocalConfig.lastBackup
if (lastBackup + TimeUnit.DAYS.toMillis(1) < System.currentTimeMillis()) {
Coroutine.async {
val lastBackupWebDav = AppWebDav.lastBackUp()
if (lastBackupWebDav == null || lastBackup > lastBackupWebDav.lastModify.time) {
if (!AppWebDav.hasBackUp()) {
backup(context, context.getPrefString(PreferKey.backupPath), true)
} else {
LocalConfig.lastBackup = System.currentTimeMillis()

Loading…
Cancel
Save