Merge pull request #736 from grote/fix-retry

Fix retries: don't upload metadata three times
This commit is contained in:
Torsten Grote 2024-09-05 16:14:20 -03:00 committed by GitHub
commit b8602fdcc2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 0 deletions

View file

@ -135,6 +135,7 @@ internal class ApkBackupManager(
for (i in 1..n) { for (i in 1..n) {
try { try {
block() block()
return
} catch (e: Exception) { } catch (e: Exception) {
if (i == n) throw e if (i == n) throw e
Log.e(TAG, "Error (#$i), we'll keep trying", e) Log.e(TAG, "Error (#$i), we'll keep trying", e)

View file

@ -234,6 +234,10 @@ internal class ApkBackupManagerTest : TransportTest() {
apkBackup.backupApkIfNecessary(notAllowedPackages[1], any()) apkBackup.backupApkIfNecessary(notAllowedPackages[1], any())
metadataOutputStream.close() metadataOutputStream.close()
} }
// metadata should only get uploaded once
verify(exactly = 1) {
metadataManager.uploadMetadata(metadataOutputStream)
}
} }
@Test @Test