From f2d166a6a45b28052662e68fda4c0f6fe0d097fe Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Mon, 15 May 2023 18:22:12 +0200 Subject: [PATCH] ui: add basic double update guard Signed-off-by: Jason A. Donenfeld --- ui/src/main/java/com/wireguard/android/updater/Updater.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ui/src/main/java/com/wireguard/android/updater/Updater.kt b/ui/src/main/java/com/wireguard/android/updater/Updater.kt index f652ae2b..dbdbacfe 100644 --- a/ui/src/main/java/com/wireguard/android/updater/Updater.kt +++ b/ui/src/main/java/com/wireguard/android/updater/Updater.kt @@ -312,13 +312,18 @@ object Updater { session.close() } + private var updating = false private suspend fun downloadAndUpdateWrapErrors() { + if (updating) + return + updating = true try { downloadAndUpdate() } catch (e: Throwable) { Log.e(TAG, "Update failure", e) emitProgress(Progress.Failure(e)) } + updating = false } private class InstallReceiver : BroadcastReceiver() {