|
|
|
@ -36,8 +36,7 @@ class AppBackupAgent : BackupAgent() {
|
|
|
|
|
|
|
|
|
|
|
|
override fun onFullBackup(data: FullBackupDataOutput) {
|
|
|
|
override fun onFullBackup(data: FullBackupDataOutput) {
|
|
|
|
super.onFullBackup(data)
|
|
|
|
super.onFullBackup(data)
|
|
|
|
val file =
|
|
|
|
val file = createBackupFile(
|
|
|
|
createBackupFile(
|
|
|
|
|
|
|
|
this,
|
|
|
|
this,
|
|
|
|
BackupRepository(
|
|
|
|
BackupRepository(
|
|
|
|
MangaDatabase(context = applicationContext),
|
|
|
|
MangaDatabase(context = applicationContext),
|
|
|
|
@ -90,8 +89,12 @@ class AppBackupAgent : BackupAgent() {
|
|
|
|
@VisibleForTesting
|
|
|
|
@VisibleForTesting
|
|
|
|
fun restoreBackupFile(fd: FileDescriptor, size: Long, repository: BackupRepository) {
|
|
|
|
fun restoreBackupFile(fd: FileDescriptor, size: Long, repository: BackupRepository) {
|
|
|
|
ZipInputStream(ByteStreams.limit(FileInputStream(fd), size)).use { input ->
|
|
|
|
ZipInputStream(ByteStreams.limit(FileInputStream(fd), size)).use { input ->
|
|
|
|
|
|
|
|
val sections = EnumSet.allOf(BackupSection::class.java)
|
|
|
|
|
|
|
|
// managed externally
|
|
|
|
|
|
|
|
sections.remove(BackupSection.SETTINGS)
|
|
|
|
|
|
|
|
sections.remove(BackupSection.SETTINGS_READER_GRID)
|
|
|
|
runBlocking {
|
|
|
|
runBlocking {
|
|
|
|
repository.restoreBackup(input, EnumSet.allOf(BackupSection::class.java), null)
|
|
|
|
repository.restoreBackup(input, sections, null)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|