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
diff --git a/app/src/main/java/com/stevesoltys/seedvault/transport/backup/BackupCoordinator.kt b/app/src/main/java/com/stevesoltys/seedvault/transport/backup/BackupCoordinator.kt
index 17a6654..70f283a 100644
--- a/app/src/main/java/com/stevesoltys/seedvault/transport/backup/BackupCoordinator.kt
+++ b/app/src/main/java/com/stevesoltys/seedvault/transport/backup/BackupCoordinator.kt
@@ -335,10 +335,12 @@
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 @@
}
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 {
diff --git a/app/src/main/java/com/stevesoltys/seedvault/transport/backup/FullBackup.kt b/app/src/main/java/com/stevesoltys/seedvault/transport/backup/FullBackup.kt
index 06ebbba..247de6d 100644
--- a/app/src/main/java/com/stevesoltys/seedvault/transport/backup/FullBackup.kt
+++ b/app/src/main/java/com/stevesoltys/seedvault/transport/backup/FullBackup.kt
@@ -177,11 +177,11 @@
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)
}
diff --git a/app/src/test/java/com/stevesoltys/seedvault/transport/backup/BackupCoordinatorTest.kt b/app/src/test/java/com/stevesoltys/seedvault/transport/backup/BackupCoordinatorTest.kt
index 915f4de..15a5ee0 100644
--- a/app/src/test/java/com/stevesoltys/seedvault/transport/backup/BackupCoordinatorTest.kt
+++ b/app/src/test/java/com/stevesoltys/seedvault/transport/backup/BackupCoordinatorTest.kt
@@ -326,7 +326,7 @@
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 @@
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
diff --git a/app/src/test/java/com/stevesoltys/seedvault/transport/backup/FullBackupTest.kt b/app/src/test/java/com/stevesoltys/seedvault/transport/backup/FullBackupTest.kt
index ed9dd25..2d03dd7 100644
--- a/app/src/test/java/com/stevesoltys/seedvault/transport/backup/FullBackupTest.kt
+++ b/app/src/test/java/com/stevesoltys/seedvault/transport/backup/FullBackupTest.kt
@@ -237,7 +237,7 @@
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 @@
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())
}