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 0ac19a1e8..7f9202ff8 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 @@ -16,12 +16,16 @@ import java.io.File object Backup { val defaultPath by lazy { - FileUtils.getSdCardPath() + File.separator + "YueDu" + File.separator + "legadoBackUp" + FileUtils.getSdCardPath() + File.separator + "YueDu" + } + + val legadoPath by lazy { + defaultPath + File.separator + "legadoBackUp" } fun backup() { doAsync { - val path = defaultPath + val path = legadoPath backupBookshelf(path) backupBookSource(path) backupRssSource(path) @@ -37,7 +41,7 @@ object Backup { fun autoBackup() { doAsync { - val path = defaultPath + val path = legadoPath backupBookshelf(path) backupBookSource(path) backupRssSource(path) diff --git a/app/src/main/java/io/legado/app/help/storage/Restore.kt b/app/src/main/java/io/legado/app/help/storage/Restore.kt index ee86570d3..3fd96c62d 100644 --- a/app/src/main/java/io/legado/app/help/storage/Restore.kt +++ b/app/src/main/java/io/legado/app/help/storage/Restore.kt @@ -16,6 +16,7 @@ import io.legado.app.help.FileHelp import io.legado.app.help.ReadBookConfig import io.legado.app.help.coroutine.Coroutine import io.legado.app.help.storage.Backup.defaultPath +import io.legado.app.help.storage.Backup.legadoPath import io.legado.app.utils.* import org.jetbrains.anko.defaultSharedPreferences import org.jetbrains.anko.doAsync @@ -32,7 +33,7 @@ object Restore { ) } - fun restore(path: String = defaultPath) { + fun restore(path: String = legadoPath) { doAsync { try { val file = FileHelp.getFile(path + File.separator + "bookshelf.json") @@ -100,9 +101,8 @@ object Restore { fun importYueDuData(context: Context) { Coroutine.async { - val file = File(FileUtils.getSdCardPath(), "YueDu") // 导入书架 - val shelfFile = File(file, "myBookShelf.json") + val shelfFile = FileHelp.getFile(defaultPath + File.separator + "myBookShelf.json") val books = mutableListOf() val items: List> = jsonPath.parse(shelfFile.readText()).read("$") val existingBooks = App.db.bookDao().allBookUrls.toSet() @@ -150,8 +150,7 @@ object Restore { Coroutine.async { // Book source - val file = File(FileUtils.getSdCardPath(), "YueDu") - val sourceFile = File(file, "myBookSource.json") + val sourceFile = FileHelp.getFile(defaultPath + File.separator + "myBookSource.json") val bookSources = mutableListOf() val items: List> = jsonPath.parse(sourceFile.readText()).read("$") for (item in items) { @@ -169,10 +168,8 @@ object Restore { } Coroutine.async { - // Book source - val file = File(FileUtils.getSdCardPath(), "YueDu") // Replace rules - val ruleFile = File(file, "myBookReplaceRule.json") + val ruleFile = FileHelp.getFile(defaultPath + File.separator + "myBookReplaceRule.json") val replaceRules = mutableListOf() val items: List> = jsonPath.parse(ruleFile.readText()).read("$") val existingRules = App.db.replaceRuleDao().all.map { it.pattern }.toSet() diff --git a/app/src/main/java/io/legado/app/help/storage/WebDavHelp.kt b/app/src/main/java/io/legado/app/help/storage/WebDavHelp.kt index 898c2d8d3..7d2022b5b 100644 --- a/app/src/main/java/io/legado/app/help/storage/WebDavHelp.kt +++ b/app/src/main/java/io/legado/app/help/storage/WebDavHelp.kt @@ -73,7 +73,7 @@ object WebDavHelp { getWebDavUrl()?.let { val file = WebDav(it + "legado/" + name) file.downloadTo(zipFilePath, true) - ZipUtils.unzipFile(zipFilePath, Backup.defaultPath) + ZipUtils.unzipFile(zipFilePath, Backup.legadoPath) Restore.restore() } }