|
|
@ -27,8 +27,9 @@ object Backup { |
|
|
|
legadoPath + File.separator + "Export" |
|
|
|
legadoPath + File.separator + "Export" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun pbackup(path :String = legadoPath){ |
|
|
|
private fun pBackup(path: String = legadoPath) { |
|
|
|
backupBookshelf(path) |
|
|
|
backupBookshelf(path) |
|
|
|
|
|
|
|
backupBookGroup(path) |
|
|
|
backupBookSource(path) |
|
|
|
backupBookSource(path) |
|
|
|
backupRssSource(path) |
|
|
|
backupRssSource(path) |
|
|
|
backupReplaceRule(path) |
|
|
|
backupReplaceRule(path) |
|
|
@ -39,7 +40,7 @@ object Backup { |
|
|
|
|
|
|
|
|
|
|
|
fun backup() { |
|
|
|
fun backup() { |
|
|
|
doAsync { |
|
|
|
doAsync { |
|
|
|
pbackup() |
|
|
|
pBackup() |
|
|
|
uiThread { |
|
|
|
uiThread { |
|
|
|
App.INSTANCE.toast(R.string.backup_success) |
|
|
|
App.INSTANCE.toast(R.string.backup_success) |
|
|
|
} |
|
|
|
} |
|
|
@ -48,7 +49,7 @@ object Backup { |
|
|
|
|
|
|
|
|
|
|
|
fun autoBackup() { |
|
|
|
fun autoBackup() { |
|
|
|
doAsync { |
|
|
|
doAsync { |
|
|
|
pbackup() |
|
|
|
pBackup() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -56,13 +57,22 @@ object Backup { |
|
|
|
App.db.bookDao().allBooks.let { |
|
|
|
App.db.bookDao().allBooks.let { |
|
|
|
if (it.isNotEmpty()) { |
|
|
|
if (it.isNotEmpty()) { |
|
|
|
val json = GSON.toJson(it) |
|
|
|
val json = GSON.toJson(it) |
|
|
|
|
|
|
|
|
|
|
|
val file = FileHelp.getFile(path + File.separator + "bookshelf.json") |
|
|
|
val file = FileHelp.getFile(path + File.separator + "bookshelf.json") |
|
|
|
file.writeText(json) |
|
|
|
file.writeText(json) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun backupBookGroup(path: String) { |
|
|
|
|
|
|
|
App.db.bookGroupDao().all().let { |
|
|
|
|
|
|
|
if (it.isNotEmpty()) { |
|
|
|
|
|
|
|
val json = GSON.toJson(it) |
|
|
|
|
|
|
|
val file = FileHelp.getFile(path + File.separator + "bookGroup.json") |
|
|
|
|
|
|
|
file.writeText(json) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun backupBookSource(path: String) { |
|
|
|
private fun backupBookSource(path: String) { |
|
|
|
App.db.bookSourceDao().all.let { |
|
|
|
App.db.bookSourceDao().all.let { |
|
|
|
if (it.isNotEmpty()) { |
|
|
|
if (it.isNotEmpty()) { |
|
|
|