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? { suspend fun lastBackUp(): WebDavFile? {
authorization?.let { authorization?.let {
var lastBackupFile: WebDavFile? = null var lastBackupFile: WebDavFile? = null

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

Loading…
Cancel
Save