pull/34/head
kunfei 5 years ago
parent d763cfe180
commit 170c7004b3
  1. 9
      app/src/main/java/io/legado/app/help/storage/Backup.kt
  2. 10
      app/src/main/java/io/legado/app/help/storage/WebDavHelp.kt

@ -1,6 +1,5 @@
package io.legado.app.help.storage package io.legado.app.help.storage
import androidx.appcompat.app.AppCompatActivity
import io.legado.app.App import io.legado.app.App
import io.legado.app.R import io.legado.app.R
import io.legado.app.help.FileHelp import io.legado.app.help.FileHelp
@ -27,21 +26,21 @@ object Backup {
backupRssSource(path) backupRssSource(path)
backupReplaceRule(path) backupReplaceRule(path)
backupPreference(path) backupPreference(path)
WebDavHelp.backUpWebDav() WebDavHelp.backUpWebDav(path)
uiThread { uiThread {
App.INSTANCE.toast(R.string.backup_success) App.INSTANCE.toast(R.string.backup_success)
} }
} }
} }
fun autoBackup(activity: AppCompatActivity) { fun autoBackup() {
doAsync { doAsync {
val path = defaultPath val path = defaultPath + File.separator + "autoBackup"
backupBookshelf(path) backupBookshelf(path)
backupBookSource(path) backupBookSource(path)
backupRssSource(path) backupRssSource(path)
backupReplaceRule(path) backupReplaceRule(path)
WebDavHelp.backUpWebDav() WebDavHelp.backUpWebDav(path)
} }
} }

@ -78,13 +78,13 @@ object WebDavHelp {
} }
} }
fun backUpWebDav() { fun backUpWebDav(path: String) {
if (initWebDav()) { if (initWebDav()) {
val paths = arrayListOf<String>() val paths = arrayListOf<String>()
paths.add(Backup.defaultPath + File.separator + "bookshelf.json") paths.add(path + File.separator + "bookshelf.json")
paths.add(Backup.defaultPath + File.separator + "bookSource.json") paths.add(path + File.separator + "bookSource.json")
paths.add(Backup.defaultPath + File.separator + "rssSource.json") paths.add(path + File.separator + "rssSource.json")
paths.add(Backup.defaultPath + File.separator + "replaceRule.json") paths.add(path + File.separator + "replaceRule.json")
FileHelp.deleteFile(zipFilePath) FileHelp.deleteFile(zipFilePath)
if (ZipUtils.zipFiles(paths, zipFilePath)) { if (ZipUtils.zipFiles(paths, zipFilePath)) {
WebDav(getWebDavUrl() + "legado").makeAsDir() WebDav(getWebDavUrl() + "legado").makeAsDir()

Loading…
Cancel
Save