Updater: don't immediately retry if check fails

If something goes wrong, maybe it's best not to DoS the update server.
Instead back off gradually and then go into the usual sleep loop.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld
2026-03-10 00:17:22 +01:00
parent 09b75c2bd3
commit 45b12811b0
@@ -410,18 +410,24 @@ object Updater {
return@launch return@launch
var waitTime = 15 var waitTime = 15
var exceptionCount = 0
while (true) { while (true) {
try { try {
val update = checkForUpdates() ?: continue val update = checkForUpdates() ?: throw Exception("No updates found")
if (update.version > CURRENT_VERSION) { if (update.version > CURRENT_VERSION) {
Log.i(TAG, "Update available: ${update.version}") Log.i(TAG, "Update available: ${update.version}")
UserKnobs.setUpdaterNewerVersionSeen(update.version.toString()) UserKnobs.setUpdaterNewerVersionSeen(update.version.toString())
return@launch return@launch
} }
} catch (_: Throwable) { } catch (_: Throwable) {
if (++exceptionCount <= 6) {
delay((exceptionCount * 8).seconds)
continue
}
} }
delay(waitTime.minutes) delay(waitTime.minutes)
waitTime = 45 waitTime = 45
exceptionCount = 0
} }
} }