Backup-restore fixes

devel
Koitharu 7 months ago
parent 391c8ab649
commit 07af3ea703
Signed by: Koitharu
GPG Key ID: 676DEE768C17A9D7

@ -55,6 +55,7 @@
android:fullBackupContent="@xml/backup_content" android:fullBackupContent="@xml/backup_content"
android:fullBackupOnly="true" android:fullBackupOnly="true"
android:hasFragileUserData="true" android:hasFragileUserData="true"
android:restoreAnyVersion="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:largeHeap="true" android:largeHeap="true"

@ -36,15 +36,14 @@ 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), AppSettings(applicationContext),
AppSettings(applicationContext), TapGridSettings(applicationContext),
TapGridSettings(applicationContext), ),
), )
)
try { try {
fullBackupFile(file, data) fullBackupFile(file, data)
} finally { } finally {
@ -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)
} }
} }
} }

@ -21,7 +21,7 @@ enum class BackupSection(
fun of(entry: ZipEntry): BackupSection? { fun of(entry: ZipEntry): BackupSection? {
val name = entry.name.lowercase(Locale.ROOT) 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 <include
domain="sharedpref" domain="sharedpref"
path="." /> path="." />
<exclude
domain="sharedpref"
path="_local_index.xml" />
<exclude
domain="database"
path="." />
<exclude
domain="device_database"
path="." />
<exclude
domain="external"
path="." />
</full-backup-content> </full-backup-content>

@ -2,5 +2,15 @@
<data-extraction-rules> <data-extraction-rules>
<cloud-backup disableIfNoEncryptionCapabilities="false"> <cloud-backup disableIfNoEncryptionCapabilities="false">
<include domain="sharedpref" path="."/> <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> </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>

Loading…
Cancel
Save