Don't try to clear data of NO_DATA system apps
This speeds up the backup quite a bit since there's many such apps
This commit is contained in:
parent
79777a7b6f
commit
b8b6882484
4 changed files with 10 additions and 10 deletions
|
@ -335,10 +335,12 @@ internal class BackupCoordinator(
|
||||||
TAG, "Cancel full backup of ${packageInfo.packageName}" +
|
TAG, "Cancel full backup of ${packageInfo.packageName}" +
|
||||||
" because of ${state.cancelReason}"
|
" because of ${state.cancelReason}"
|
||||||
)
|
)
|
||||||
onPackageBackupError(packageInfo, BackupType.FULL)
|
// don't bother with system apps that have no data
|
||||||
|
val ignoreApp = state.cancelReason == NO_DATA && packageInfo.isSystemApp()
|
||||||
|
if (!ignoreApp) onPackageBackupError(packageInfo, BackupType.FULL)
|
||||||
val token = settingsManager.getToken() ?: error("no token in cancelFullBackup")
|
val token = settingsManager.getToken() ?: error("no token in cancelFullBackup")
|
||||||
val salt = metadataManager.salt
|
val salt = metadataManager.salt
|
||||||
full.cancelFullBackup(token, salt)
|
full.cancelFullBackup(token, salt, ignoreApp)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear and Finish
|
// Clear and Finish
|
||||||
|
@ -482,8 +484,6 @@ internal class BackupCoordinator(
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun onPackageBackupError(packageInfo: PackageInfo, type: BackupType) {
|
private suspend fun onPackageBackupError(packageInfo: PackageInfo, type: BackupType) {
|
||||||
// don't bother with system apps that have no data
|
|
||||||
if (state.cancelReason == NO_DATA && packageInfo.isSystemApp()) return
|
|
||||||
val packageName = packageInfo.packageName
|
val packageName = packageInfo.packageName
|
||||||
try {
|
try {
|
||||||
plugin.getMetadataOutputStream().use {
|
plugin.getMetadataOutputStream().use {
|
||||||
|
|
|
@ -177,11 +177,11 @@ internal class FullBackup(
|
||||||
plugin.removeData(token, name)
|
plugin.removeData(token, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun cancelFullBackup(token: Long, salt: String) {
|
suspend fun cancelFullBackup(token: Long, salt: String, ignoreApp: Boolean) {
|
||||||
Log.i(TAG, "Cancel full backup")
|
Log.i(TAG, "Cancel full backup")
|
||||||
val state = this.state ?: throw AssertionError("No state when canceling")
|
val state = this.state ?: throw AssertionError("No state when canceling")
|
||||||
try {
|
try {
|
||||||
clearBackupData(state.packageInfo, token, salt)
|
if (!ignoreApp) clearBackupData(state.packageInfo, token, salt)
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
Log.w(TAG, "Error cancelling full backup for ${state.packageName}", e)
|
Log.w(TAG, "Error cancelling full backup for ${state.packageName}", e)
|
||||||
}
|
}
|
||||||
|
|
|
@ -326,7 +326,7 @@ internal class BackupCoordinatorTest : BackupTest() {
|
||||||
BackupType.FULL
|
BackupType.FULL
|
||||||
)
|
)
|
||||||
} just Runs
|
} just Runs
|
||||||
coEvery { full.cancelFullBackup(token, metadata.salt) } just Runs
|
coEvery { full.cancelFullBackup(token, metadata.salt, false) } just Runs
|
||||||
every { settingsManager.getStorage() } returns storage
|
every { settingsManager.getStorage() } returns storage
|
||||||
every { metadataOutputStream.close() } just Runs
|
every { metadataOutputStream.close() } just Runs
|
||||||
|
|
||||||
|
@ -375,7 +375,7 @@ internal class BackupCoordinatorTest : BackupTest() {
|
||||||
BackupType.FULL
|
BackupType.FULL
|
||||||
)
|
)
|
||||||
} just Runs
|
} just Runs
|
||||||
coEvery { full.cancelFullBackup(token, metadata.salt) } just Runs
|
coEvery { full.cancelFullBackup(token, metadata.salt, false) } just Runs
|
||||||
every { settingsManager.getStorage() } returns storage
|
every { settingsManager.getStorage() } returns storage
|
||||||
every { metadataOutputStream.close() } just Runs
|
every { metadataOutputStream.close() } just Runs
|
||||||
|
|
||||||
|
|
|
@ -237,7 +237,7 @@ internal class FullBackupTest : BackupTest() {
|
||||||
|
|
||||||
assertEquals(TRANSPORT_OK, backup.performFullBackup(packageInfo, data, 0, token, salt))
|
assertEquals(TRANSPORT_OK, backup.performFullBackup(packageInfo, data, 0, token, salt))
|
||||||
assertTrue(backup.hasState())
|
assertTrue(backup.hasState())
|
||||||
backup.cancelFullBackup(token, salt)
|
backup.cancelFullBackup(token, salt, false)
|
||||||
assertFalse(backup.hasState())
|
assertFalse(backup.hasState())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,7 +251,7 @@ internal class FullBackupTest : BackupTest() {
|
||||||
|
|
||||||
assertEquals(TRANSPORT_OK, backup.performFullBackup(packageInfo, data, 0, token, salt))
|
assertEquals(TRANSPORT_OK, backup.performFullBackup(packageInfo, data, 0, token, salt))
|
||||||
assertTrue(backup.hasState())
|
assertTrue(backup.hasState())
|
||||||
backup.cancelFullBackup(token, salt)
|
backup.cancelFullBackup(token, salt, false)
|
||||||
assertFalse(backup.hasState())
|
assertFalse(backup.hasState())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue