From 32aad5aecd0b46585f77abe255c17ebe61f6fecb Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 26 Feb 2022 09:48:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 4 ++++ .../java/io/legado/app/help/storage/Backup.kt | 18 +++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index e3557a5fc..9d29de491 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -11,6 +11,10 @@ * 正文出现缺字漏字、内容缺失、排版错乱等情况,有可能是净化规则或简繁转换出现问题。 * 漫画源看书显示乱码,**阅读与其他软件的源并不通用**,请导入阅读的支持的漫画源! +**2022/02/26** + +* 自动备份检测到webDav已有备份时不会重复备份 + **2022/02/25** * 修复排版导入不能导入背景图片的bug diff --git a/app/src/main/java/io/legado/app/help/storage/Backup.kt b/app/src/main/java/io/legado/app/help/storage/Backup.kt index 2979a0c31..b8e649fe6 100644 --- a/app/src/main/java/io/legado/app/help/storage/Backup.kt +++ b/app/src/main/java/io/legado/app/help/storage/Backup.kt @@ -52,7 +52,9 @@ object Backup : BackupRestore() { if (lastBackup + TimeUnit.DAYS.toMillis(1) < System.currentTimeMillis()) { Coroutine.async { if (!AppWebDav.hasBackUp()) { - backup(context, context.getPrefString(PreferKey.backupPath) ?: "", true) + backup(context, context.getPrefString(PreferKey.backupPath), true) + } else { + context.putPrefLong(PreferKey.lastBackup, System.currentTimeMillis()) } }.onError { AppLog.put("备份出错\n${it.localizedMessage}", it) @@ -61,7 +63,7 @@ object Backup : BackupRestore() { } } - suspend fun backup(context: Context, path: String, isAuto: Boolean = false) { + suspend fun backup(context: Context, path: String?, isAuto: Boolean = false) { context.putPrefLong(PreferKey.lastBackup, System.currentTimeMillis()) withContext(IO) { FileUtils.deleteFile(backupPath) @@ -105,12 +107,14 @@ object Backup : BackupRestore() { edit.commit() } AppWebDav.backUpWebDav(backupPath) - if (path.isContentScheme()) { - copyBackup(context, Uri.parse(path), isAuto) - } else { - if (path.isEmpty()) { + when { + path.isNullOrBlank() -> { copyBackup(context.getExternalFilesDir(null)!!, false) - } else { + } + path.isContentScheme() -> { + copyBackup(context, Uri.parse(path), isAuto) + } + else -> { copyBackup(File(path), isAuto) } }