Merge pull request #115 from hingbong/master

修复: 每次备份都将之前的备份文件删除
pull/379/head
kunfei 5 years ago committed by GitHub
commit b1ecf66769
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      app/src/main/java/io/legado/app/help/storage/Backup.kt

@ -100,12 +100,16 @@ object Backup {
for (fileName in backupFileNames) { for (fileName in backupFileNames) {
val file = File(backupPath + File.separator + fileName) val file = File(backupPath + File.separator + fileName)
if (file.exists()) { if (file.exists()) {
val doc = treeDoc.findFile(fileName) ?: treeDoc.createFile("", fileName) var doc = treeDoc.findFile(fileName)
if (null != doc && doc.exists()) {
doc.delete()
}
doc = treeDoc.createFile("", fileName)
doc?.let { doc?.let {
DocumentUtils.writeText( DocumentUtils.writeText(
context, context,
file.readText(), file.readText(),
doc.uri it.uri
) )
} }
} }

Loading…
Cancel
Save