mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
fix: check a Battle.net game for updates again when the last check failed
This commit is contained in:
1 parent
24f0b97c08
commit
db56cff880
2 files changed
+19
-4
No files matched your search
@@ -45,8 +45,8 @@ object BattleNetInstall {
|
||||
"zhTW", "zhCN", "thTH", "arSA",
|
||||
)
|
||||
|
||||
private val checks = Executors.newSingleThreadExecutor { r -> Thread(r, "battlenet-updates") }
|
||||
private val checkedAt = HashMap<String, Long>()
|
||||
internal val checks = Executors.newSingleThreadExecutor { r -> Thread(r, "battlenet-updates") }
|
||||
internal val checkedAt = HashMap<String, Long>()
|
||||
|
||||
val updates = mutableStateMapOf<String, Boolean>()
|
||||
|
||||
@@ -177,10 +177,13 @@ object BattleNetInstall {
|
||||
if (!force && now - (checkedAt[id] ?: 0L) < CHECK_AGAIN_MS) return
|
||||
checkedAt[id] = now
|
||||
}
|
||||
fun retryLater() = synchronized(checkedAt) { if (checkedAt[id] == now) checkedAt.remove(id) }
|
||||
checks.execute {
|
||||
val local = runCatching { buildKey(File(folder, BUILD_INFO).readText()) }.getOrNull() ?: return@execute
|
||||
val local = runCatching { buildKey(File(folder, BUILD_INFO).readText()) }.getOrNull()
|
||||
?: return@execute retryLater()
|
||||
val latest = runCatching { latestBuild(fetch(VERSIONS.format(Locale.ROOT, local.first, product)), local.first) }
|
||||
.onFailure { Log.w(TAG, "versions of $product: ${it.javaClass.simpleName}") }.getOrNull() ?: return@execute
|
||||
.onFailure { Log.w(TAG, "versions of $product: ${it.javaClass.simpleName}") }.getOrNull()
|
||||
?: return@execute retryLater()
|
||||
val behind = latest != local.second
|
||||
Log.i(TAG, "$id: ${if (behind) "update available" else "up to date"}")
|
||||
StoresState.post { if (behind) updates[id] = true else updates.remove(id) }
|
||||
|
||||
Reference in new issue
Block a user