Backup-restore fixes
This commit is contained in:
@@ -55,6 +55,7 @@
|
||||
android:fullBackupContent="@xml/backup_content"
|
||||
android:fullBackupOnly="true"
|
||||
android:hasFragileUserData="true"
|
||||
android:restoreAnyVersion="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:largeHeap="true"
|
||||
|
||||
@@ -36,15 +36,14 @@ class AppBackupAgent : BackupAgent() {
|
||||
|
||||
override fun onFullBackup(data: FullBackupDataOutput) {
|
||||
super.onFullBackup(data)
|
||||
val file =
|
||||
createBackupFile(
|
||||
this,
|
||||
BackupRepository(
|
||||
MangaDatabase(context = applicationContext),
|
||||
AppSettings(applicationContext),
|
||||
TapGridSettings(applicationContext),
|
||||
),
|
||||
)
|
||||
val file = createBackupFile(
|
||||
this,
|
||||
BackupRepository(
|
||||
MangaDatabase(context = applicationContext),
|
||||
AppSettings(applicationContext),
|
||||
TapGridSettings(applicationContext),
|
||||
),
|
||||
)
|
||||
try {
|
||||
fullBackupFile(file, data)
|
||||
} finally {
|
||||
@@ -90,8 +89,12 @@ class AppBackupAgent : BackupAgent() {
|
||||
@VisibleForTesting
|
||||
fun restoreBackupFile(fd: FileDescriptor, size: Long, repository: BackupRepository) {
|
||||
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 {
|
||||
repository.restoreBackup(input, EnumSet.allOf(BackupSection::class.java), null)
|
||||
repository.restoreBackup(input, sections, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ enum class BackupSection(
|
||||
|
||||
fun of(entry: ZipEntry): BackupSection? {
|
||||
val name = entry.name.lowercase(Locale.ROOT)
|
||||
return entries.first { x -> x.entryName == name }
|
||||
return entries.find { x -> x.entryName == name }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,16 @@
|
||||
<include
|
||||
domain="sharedpref"
|
||||
path="." />
|
||||
<exclude
|
||||
domain="sharedpref"
|
||||
path="_local_index.xml" />
|
||||
<exclude
|
||||
domain="database"
|
||||
path="." />
|
||||
<exclude
|
||||
domain="device_database"
|
||||
path="." />
|
||||
<exclude
|
||||
domain="external"
|
||||
path="." />
|
||||
</full-backup-content>
|
||||
|
||||
@@ -2,5 +2,15 @@
|
||||
<data-extraction-rules>
|
||||
<cloud-backup disableIfNoEncryptionCapabilities="false">
|
||||
<include domain="sharedpref" path="."/>
|
||||
<exclude domain="sharedpref" path="_local_index.xml"/>
|
||||
<exclude domain="database" path="." />
|
||||
<exclude domain="device_database" path="." />
|
||||
<exclude domain="external" path="." />
|
||||
</cloud-backup>
|
||||
</data-extraction-rules>
|
||||
<device-transfer>
|
||||
<include domain="sharedpref" path="."/>
|
||||
<exclude domain="sharedpref" path="_local_index.xml"/>
|
||||
<exclude domain="database" path="." />
|
||||
<exclude domain="device_database" path="." />
|
||||
</device-transfer>
|
||||
</data-extraction-rules>
|
||||
|
||||
Reference in New Issue
Block a user