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}" +
|
||||
" 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 salt = metadataManager.salt
|
||||
full.cancelFullBackup(token, salt)
|
||||
full.cancelFullBackup(token, salt, ignoreApp)
|
||||
}
|
||||
|
||||
// Clear and Finish
|
||||
|
@ -482,8 +484,6 @@ internal class BackupCoordinator(
|
|||
}
|
||||
|
||||
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
|
||||
try {
|
||||
plugin.getMetadataOutputStream().use {
|
||||
|
|
|
@ -177,11 +177,11 @@ internal class FullBackup(
|
|||
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")
|
||||
val state = this.state ?: throw AssertionError("No state when canceling")
|
||||
try {
|
||||
clearBackupData(state.packageInfo, token, salt)
|
||||
if (!ignoreApp) clearBackupData(state.packageInfo, token, salt)
|
||||
} catch (e: IOException) {
|
||||
Log.w(TAG, "Error cancelling full backup for ${state.packageName}", e)
|
||||
}
|
||||
|
|
|
@ -326,7 +326,7 @@ internal class BackupCoordinatorTest : BackupTest() {
|
|||
BackupType.FULL
|
||||
)
|
||||
} 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 { metadataOutputStream.close() } just Runs
|
||||
|
||||
|
@ -375,7 +375,7 @@ internal class BackupCoordinatorTest : BackupTest() {
|
|||
BackupType.FULL
|
||||
)
|
||||
} 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 { metadataOutputStream.close() } just Runs
|
||||
|
||||
|
|
|
@ -237,7 +237,7 @@ internal class FullBackupTest : BackupTest() {
|
|||
|
||||
assertEquals(TRANSPORT_OK, backup.performFullBackup(packageInfo, data, 0, token, salt))
|
||||
assertTrue(backup.hasState())
|
||||
backup.cancelFullBackup(token, salt)
|
||||
backup.cancelFullBackup(token, salt, false)
|
||||
assertFalse(backup.hasState())
|
||||
}
|
||||
|
||||
|
@ -251,7 +251,7 @@ internal class FullBackupTest : BackupTest() {
|
|||
|
||||
assertEquals(TRANSPORT_OK, backup.performFullBackup(packageInfo, data, 0, token, salt))
|
||||
assertTrue(backup.hasState())
|
||||
backup.cancelFullBackup(token, salt)
|
||||
backup.cancelFullBackup(token, salt, false)
|
||||
assertFalse(backup.hasState())
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue