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:
1 parent
09b75c2bd3
commit
45b12811b0
1 file changed
+7
-1
@@ -410,18 +410,24 @@ object Updater {
|
||||
return@launch
|
||||
|
||||
var waitTime = 15
|
||||
var exceptionCount = 0
|
||||
while (true) {
|
||||
try {
|
||||
val update = checkForUpdates() ?: continue
|
||||
val update = checkForUpdates() ?: throw Exception("No updates found")
|
||||
if (update.version > CURRENT_VERSION) {
|
||||
Log.i(TAG, "Update available: ${update.version}")
|
||||
UserKnobs.setUpdaterNewerVersionSeen(update.version.toString())
|
||||
return@launch
|
||||
}
|
||||
} catch (_: Throwable) {
|
||||
if (++exceptionCount <= 6) {
|
||||
delay((exceptionCount * 8).seconds)
|
||||
continue
|
||||
}
|
||||
}
|
||||
delay(waitTime.minutes)
|
||||
waitTime = 45
|
||||
exceptionCount = 0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user