mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
fix(battlenet): a download that stops moving ends with Retry, and a killed update comes back as an update (#2602)
* fix(battlenet): a Battle.net download that stops moving ends as retryable, and a killed update comes back as an update A job reply without a state or byte counts no longer counts as a started download, and an Agent job that reports no change for ten minutes is stopped with its Agent and fails with a Retry instead of waiting forever. Updates remember their game folder in the saved queue, so one restored after the app was closed runs agent-update on that folder instead of a fresh install. * fix(battlenet): a stalled job stops only the Agent it started A game or Battle.net client running in the prefix keeps running when a stalled Agent job is ended, and the progress test keeps the job alive across polls with a controlled clock. * fix(battlenet): only real progress holds off the stall timeout The download rate and time estimate can change while no bytes move, so the stall timer now resets only on byte counts, progress, state, phase, pause or error. * test(battlenet): bound the stalled-rate fake child's polls
This commit is contained in:
1 parent
84b7295f11
commit
d8b3c66b95
38 files changed
+218
-6
No files matched your search
@@ -111,16 +111,22 @@ object BattleNetInstall {
|
||||
fun update(context: Context, game: InstalledStoreGame) {
|
||||
val app = context.applicationContext
|
||||
Thread({
|
||||
val item = CatalogItem(
|
||||
Store.BATTLENET, game.sidecar.id, game.sidecar.title, game.sidecar.hero, tallImageUrl = game.sidecar.cover, owned = true,
|
||||
extra = mapOf(INSTALL_UID to installUid(app, game)),
|
||||
)
|
||||
val item = updateItem(game, installUid(app, game))
|
||||
game.folder.parentFile?.parentFile?.let { com.droiddeck.launcher.stores.download.SavedQueue.remember(app, item, it) }
|
||||
enqueue(app, item, game.folder, update = true)
|
||||
}, "battlenet-update").start()
|
||||
}
|
||||
|
||||
internal fun updateItem(game: InstalledStoreGame, uid: String) = CatalogItem(
|
||||
Store.BATTLENET, game.sidecar.id, game.sidecar.title, game.sidecar.hero, tallImageUrl = game.sidecar.cover, owned = true,
|
||||
extra = mapOf(INSTALL_UID to uid, UPDATE_FOLDER to game.folder.absolutePath),
|
||||
)
|
||||
|
||||
internal fun updateFolder(item: CatalogItem): File? = item.extra[UPDATE_FOLDER]?.let(::File)
|
||||
|
||||
internal const val INSTALL_UID = "installUid"
|
||||
internal const val UPDATE_FOLDER = "updateFolder"
|
||||
internal const val STALLED = "stalled"
|
||||
|
||||
internal fun installUid(context: Context, game: InstalledStoreGame): String =
|
||||
runCatching { BattleNet.games(context).firstOrNull { it.uid == game.sidecar.id }?.installUid }.getOrNull() ?: game.sidecar.id
|
||||
@@ -219,6 +225,7 @@ object BattleNetInstall {
|
||||
val detail = when {
|
||||
reason == null -> "exit $code"
|
||||
reason == "client" -> return context.getString(R.string.bnet_dl_client_first)
|
||||
reason == STALLED -> return context.getString(R.string.bnet_dl_stalled)
|
||||
reason.startsWith("agent ") -> context.getString(R.string.bnet_dl_agent_error, reason.removePrefix("agent "))
|
||||
else -> reason.removePrefix("stopped ")
|
||||
}
|
||||
|
||||
@@ -192,6 +192,7 @@ object BattleNetBackend : StoreBackend {
|
||||
override fun install(context: Context, item: CatalogItem, root: File) {
|
||||
if (!BattleNetInstall.headless(item)) return BattleNetClient.installGame(context, item.id, root)
|
||||
val app = context.applicationContext
|
||||
BattleNetInstall.updateFolder(item)?.let { return BattleNetInstall.enqueue(app, item, it, update = true) }
|
||||
BattleNetInstall.enqueue(app, item, StoreInstallRoot.folderFor(app, store, item.id, item.title, root))
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user