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))
|
||||
}
|
||||
|
||||
|
||||
@@ -2605,6 +2605,7 @@
|
||||
<string name="bnet_dl_queued">في انتظار تنزيل Battle.net الآخر…</string>
|
||||
<string name="bnet_dl_client_first">افتح Battle.net وسجّل الدخول مرة واحدة، ثم ثبّت ألعابه من هنا.</string>
|
||||
<string name="bnet_dl_failed">توقفت أداة التنزيل من Blizzard: %1$s</string>
|
||||
<string name="bnet_dl_stalled">توقفت أداة التنزيل من Blizzard عن التقدم.</string>
|
||||
<string name="bnet_dl_agent_error">خطأ Blizzard %1$s</string>
|
||||
<string name="bnet_update">تحديث</string>
|
||||
<string name="bnet_store">ألعاب Blizzard</string>
|
||||
|
||||
@@ -2571,6 +2571,7 @@
|
||||
<string name="bnet_dl_queued">Esperando la otra descarga de Battle.net…</string>
|
||||
<string name="bnet_dl_client_first">Abre Battle.net e inicia sesión una vez; luego instala sus juegos desde aquí.</string>
|
||||
<string name="bnet_dl_failed">El descargador de Blizzard se detuvo: %1$s</string>
|
||||
<string name="bnet_dl_stalled">El descargador de Blizzard dejó de avanzar.</string>
|
||||
<string name="bnet_dl_agent_error">Error de Blizzard %1$s</string>
|
||||
<string name="bnet_update">Actualizar</string>
|
||||
<string name="bnet_store">Juegos de Blizzard</string>
|
||||
|
||||
@@ -2501,6 +2501,7 @@
|
||||
<string name="bnet_dl_queued">Изчакване на другото изтегляне от Battle.net…</string>
|
||||
<string name="bnet_dl_client_first">Отворете Battle.net и влезте веднъж, след това инсталирайте игрите му оттук.</string>
|
||||
<string name="bnet_dl_failed">Програмата за изтегляне на Blizzard спря: %1$s</string>
|
||||
<string name="bnet_dl_stalled">Програмата за изтегляне на Blizzard спря да напредва.</string>
|
||||
<string name="bnet_dl_agent_error">Грешка на Blizzard %1$s</string>
|
||||
<string name="bnet_update">Актуализиране</string>
|
||||
<string name="bnet_store">Игри на Blizzard</string>
|
||||
|
||||
@@ -2553,6 +2553,7 @@
|
||||
<string name="bnet_dl_queued">Čekání na druhé stahování z Battle.net…</string>
|
||||
<string name="bnet_dl_client_first">Otevřete Battle.net a jednou se přihlaste, pak instalujte jeho hry odsud.</string>
|
||||
<string name="bnet_dl_failed">Stahovač Blizzardu se zastavil: %1$s</string>
|
||||
<string name="bnet_dl_stalled">Stahovač Blizzardu přestal postupovat.</string>
|
||||
<string name="bnet_dl_agent_error">Chyba Blizzardu %1$s</string>
|
||||
<string name="bnet_update">Aktualizovat</string>
|
||||
<string name="bnet_store">Hry od Blizzardu</string>
|
||||
|
||||
@@ -2501,6 +2501,7 @@
|
||||
<string name="bnet_dl_queued">Venter på den anden Battle.net-download…</string>
|
||||
<string name="bnet_dl_client_first">Åbn Battle.net, og log ind én gang, og installer derefter dets spil herfra.</string>
|
||||
<string name="bnet_dl_failed">Blizzards downloader stoppede: %1$s</string>
|
||||
<string name="bnet_dl_stalled">Blizzards downloader holdt op med at gøre fremskridt.</string>
|
||||
<string name="bnet_dl_agent_error">Blizzard-fejl %1$s</string>
|
||||
<string name="bnet_update">Opdater</string>
|
||||
<string name="bnet_store">Blizzard-spil</string>
|
||||
|
||||
@@ -2493,6 +2493,7 @@
|
||||
<string name="bnet_dl_queued">Warten auf den anderen Battle.net-Download…</string>
|
||||
<string name="bnet_dl_client_first">Öffne Battle.net und melde dich einmal an, dann installiere seine Spiele hier.</string>
|
||||
<string name="bnet_dl_failed">Blizzards Downloader wurde beendet: %1$s</string>
|
||||
<string name="bnet_dl_stalled">Blizzards Downloader kommt nicht mehr voran.</string>
|
||||
<string name="bnet_dl_agent_error">Blizzard-Fehler %1$s</string>
|
||||
<string name="bnet_update">Aktualisieren</string>
|
||||
<string name="bnet_store">Blizzard-Spiele</string>
|
||||
|
||||
@@ -2501,6 +2501,7 @@
|
||||
<string name="bnet_dl_queued">Αναμονή για την άλλη λήψη από το Battle.net…</string>
|
||||
<string name="bnet_dl_client_first">Ανοίξτε το Battle.net και συνδεθείτε μία φορά, έπειτα εγκαταστήστε τα παιχνίδια του από εδώ.</string>
|
||||
<string name="bnet_dl_failed">Το πρόγραμμα λήψης της Blizzard σταμάτησε: %1$s</string>
|
||||
<string name="bnet_dl_stalled">Το πρόγραμμα λήψης της Blizzard σταμάτησε να προχωρά.</string>
|
||||
<string name="bnet_dl_agent_error">Σφάλμα Blizzard %1$s</string>
|
||||
<string name="bnet_update">Ενημέρωση</string>
|
||||
<string name="bnet_store">Παιχνίδια της Blizzard</string>
|
||||
|
||||
@@ -2527,6 +2527,7 @@
|
||||
<string name="bnet_dl_queued">Esperando a la otra descarga de Battle.net…</string>
|
||||
<string name="bnet_dl_client_first">Abre Battle.net e inicia sesión una vez; después instala sus juegos desde aquí.</string>
|
||||
<string name="bnet_dl_failed">El descargador de Blizzard se ha detenido: %1$s</string>
|
||||
<string name="bnet_dl_stalled">El descargador de Blizzard ha dejado de avanzar.</string>
|
||||
<string name="bnet_dl_agent_error">Error de Blizzard %1$s</string>
|
||||
<string name="bnet_update">Actualizar</string>
|
||||
<string name="bnet_store">Juegos de Blizzard</string>
|
||||
|
||||
@@ -2501,6 +2501,7 @@
|
||||
<string name="bnet_dl_queued">Odotetaan toista Battle.net-latausta…</string>
|
||||
<string name="bnet_dl_client_first">Avaa Battle.net ja kirjaudu sisään kerran, asenna sitten sen pelit täältä.</string>
|
||||
<string name="bnet_dl_failed">Blizzardin latausohjelma pysähtyi: %1$s</string>
|
||||
<string name="bnet_dl_stalled">Blizzardin latausohjelma lakkasi etenemästä.</string>
|
||||
<string name="bnet_dl_agent_error">Blizzard-virhe %1$s</string>
|
||||
<string name="bnet_update">Päivitä</string>
|
||||
<string name="bnet_store">Blizzardin pelit</string>
|
||||
|
||||
@@ -2526,6 +2526,7 @@
|
||||
<string name="bnet_dl_queued">En attente de l\'autre téléchargement Battle.net…</string>
|
||||
<string name="bnet_dl_client_first">Ouvrez Battle.net et connectez-vous une fois, puis installez ses jeux ici.</string>
|
||||
<string name="bnet_dl_failed">Le téléchargeur de Blizzard s\'est arrêté : %1$s</string>
|
||||
<string name="bnet_dl_stalled">Le téléchargeur de Blizzard n\'avance plus.</string>
|
||||
<string name="bnet_dl_agent_error">Erreur Blizzard %1$s</string>
|
||||
<string name="bnet_update">Mettre à jour</string>
|
||||
<string name="bnet_store">Jeux Blizzard</string>
|
||||
|
||||
@@ -2501,6 +2501,7 @@
|
||||
<string name="bnet_dl_queued">दूसरे Battle.net डाउनलोड का इंतज़ार…</string>
|
||||
<string name="bnet_dl_client_first">Battle.net खोलें और एक बार साइन इन करें, फिर इसके गेम यहाँ से इंस्टॉल करें।</string>
|
||||
<string name="bnet_dl_failed">Blizzard का डाउनलोडर रुक गया: %1$s</string>
|
||||
<string name="bnet_dl_stalled">Blizzard का डाउनलोडर आगे नहीं बढ़ रहा।</string>
|
||||
<string name="bnet_dl_agent_error">Blizzard त्रुटि %1$s</string>
|
||||
<string name="bnet_update">अपडेट करें</string>
|
||||
<string name="bnet_store">Blizzard के गेम</string>
|
||||
|
||||
@@ -2501,6 +2501,7 @@
|
||||
<string name="bnet_dl_queued">Várakozás a másik Battle.net-letöltésre…</string>
|
||||
<string name="bnet_dl_client_first">Nyisd meg a Battle.netet, és jelentkezz be egyszer, majd innen telepítsd a játékait.</string>
|
||||
<string name="bnet_dl_failed">A Blizzard letöltője leállt: %1$s</string>
|
||||
<string name="bnet_dl_stalled">A Blizzard letöltője nem halad tovább.</string>
|
||||
<string name="bnet_dl_agent_error">Blizzard-hiba: %1$s</string>
|
||||
<string name="bnet_update">Frissítés</string>
|
||||
<string name="bnet_store">Blizzard-játékok</string>
|
||||
|
||||
@@ -2476,6 +2476,7 @@
|
||||
<string name="bnet_dl_queued">Menunggu unduhan Battle.net lainnya…</string>
|
||||
<string name="bnet_dl_client_first">Buka Battle.net dan masuk sekali, lalu instal gamenya dari sini.</string>
|
||||
<string name="bnet_dl_failed">Pengunduh Blizzard berhenti: %1$s</string>
|
||||
<string name="bnet_dl_stalled">Pengunduh Blizzard berhenti berjalan.</string>
|
||||
<string name="bnet_dl_agent_error">Kesalahan Blizzard %1$s</string>
|
||||
<string name="bnet_update">Perbarui</string>
|
||||
<string name="bnet_store">Game Blizzard</string>
|
||||
|
||||
@@ -2518,6 +2518,7 @@
|
||||
<string name="bnet_dl_queued">In attesa dell\'altro download di Battle.net…</string>
|
||||
<string name="bnet_dl_client_first">Apri Battle.net ed esegui l\'accesso una volta, poi installa qui i suoi giochi.</string>
|
||||
<string name="bnet_dl_failed">Il downloader di Blizzard si è fermato: %1$s</string>
|
||||
<string name="bnet_dl_stalled">Il downloader di Blizzard ha smesso di avanzare.</string>
|
||||
<string name="bnet_dl_agent_error">Errore Blizzard %1$s</string>
|
||||
<string name="bnet_update">Aggiorna</string>
|
||||
<string name="bnet_store">Giochi Blizzard</string>
|
||||
|
||||
@@ -2476,6 +2476,7 @@
|
||||
<string name="bnet_dl_queued">もう一つの Battle.net のダウンロードを待っています…</string>
|
||||
<string name="bnet_dl_client_first">Battle.net を開いて一度サインインしてから、ここでゲームをインストールしてください。</string>
|
||||
<string name="bnet_dl_failed">Blizzard のダウンローダーが停止しました: %1$s</string>
|
||||
<string name="bnet_dl_stalled">Blizzard のダウンローダーが進まなくなりました。</string>
|
||||
<string name="bnet_dl_agent_error">Blizzard エラー %1$s</string>
|
||||
<string name="bnet_update">アップデート</string>
|
||||
<string name="bnet_store">Blizzard のゲーム</string>
|
||||
|
||||
@@ -2476,6 +2476,7 @@
|
||||
<string name="bnet_dl_queued">다른 Battle.net 다운로드를 기다리는 중…</string>
|
||||
<string name="bnet_dl_client_first">Battle.net을 열고 한 번 로그인한 다음 여기에서 게임을 설치하세요.</string>
|
||||
<string name="bnet_dl_failed">Blizzard 다운로더가 중지됨: %1$s</string>
|
||||
<string name="bnet_dl_stalled">Blizzard 다운로더가 더 이상 진행되지 않습니다.</string>
|
||||
<string name="bnet_dl_agent_error">Blizzard 오류 %1$s</string>
|
||||
<string name="bnet_update">업데이트</string>
|
||||
<string name="bnet_store">Blizzard 게임</string>
|
||||
|
||||
@@ -2476,6 +2476,7 @@
|
||||
<string name="bnet_dl_queued">Menunggu muat turun Battle.net yang lain…</string>
|
||||
<string name="bnet_dl_client_first">Buka Battle.net dan log masuk sekali, kemudian pasang permainannya dari sini.</string>
|
||||
<string name="bnet_dl_failed">Pemuat turun Blizzard berhenti: %1$s</string>
|
||||
<string name="bnet_dl_stalled">Pemuat turun Blizzard berhenti bergerak.</string>
|
||||
<string name="bnet_dl_agent_error">Ralat Blizzard %1$s</string>
|
||||
<string name="bnet_update">Kemas kini</string>
|
||||
<string name="bnet_store">Permainan Blizzard</string>
|
||||
|
||||
@@ -2501,6 +2501,7 @@
|
||||
<string name="bnet_dl_queued">Venter på den andre Battle.net-nedlastingen…</string>
|
||||
<string name="bnet_dl_client_first">Åpne Battle.net og logg på én gang, og installer deretter spillene herfra.</string>
|
||||
<string name="bnet_dl_failed">Blizzards nedlaster stoppet: %1$s</string>
|
||||
<string name="bnet_dl_stalled">Blizzards nedlaster sluttet å gjøre fremgang.</string>
|
||||
<string name="bnet_dl_agent_error">Blizzard-feil %1$s</string>
|
||||
<string name="bnet_update">Oppdater</string>
|
||||
<string name="bnet_store">Blizzard-spill</string>
|
||||
|
||||
@@ -2501,6 +2501,7 @@
|
||||
<string name="bnet_dl_queued">Wachten op de andere Battle.net-download…</string>
|
||||
<string name="bnet_dl_client_first">Open Battle.net en meld je één keer aan, installeer daarna de games hier.</string>
|
||||
<string name="bnet_dl_failed">Blizzards downloader is gestopt: %1$s</string>
|
||||
<string name="bnet_dl_stalled">Blizzards downloader maakt geen voortgang meer.</string>
|
||||
<string name="bnet_dl_agent_error">Blizzard-fout %1$s</string>
|
||||
<string name="bnet_update">Bijwerken</string>
|
||||
<string name="bnet_store">Blizzard-games</string>
|
||||
|
||||
@@ -2553,6 +2553,7 @@
|
||||
<string name="bnet_dl_queued">Oczekiwanie na drugie pobieranie z Battle.net…</string>
|
||||
<string name="bnet_dl_client_first">Otwórz Battle.net i zaloguj się raz, a potem instaluj jego gry tutaj.</string>
|
||||
<string name="bnet_dl_failed">Program pobierający Blizzarda zatrzymał się: %1$s</string>
|
||||
<string name="bnet_dl_stalled">Program pobierający Blizzarda przestał robić postępy.</string>
|
||||
<string name="bnet_dl_agent_error">Błąd Blizzarda %1$s</string>
|
||||
<string name="bnet_update">Aktualizuj</string>
|
||||
<string name="bnet_store">Gry Blizzarda</string>
|
||||
|
||||
@@ -2518,6 +2518,7 @@
|
||||
<string name="bnet_dl_queued">A aguardar a outra transferência do Battle.net…</string>
|
||||
<string name="bnet_dl_client_first">Abra o Battle.net e inicie sessão uma vez; depois instale os jogos dele aqui.</string>
|
||||
<string name="bnet_dl_failed">O programa de transferência da Blizzard parou: %1$s</string>
|
||||
<string name="bnet_dl_stalled">O programa de transferência da Blizzard deixou de avançar.</string>
|
||||
<string name="bnet_dl_agent_error">Erro da Blizzard %1$s</string>
|
||||
<string name="bnet_update">Atualizar</string>
|
||||
<string name="bnet_store">Jogos da Blizzard</string>
|
||||
|
||||
@@ -2519,6 +2519,7 @@
|
||||
<string name="bnet_dl_queued">Aguardando o outro download do Battle.net…</string>
|
||||
<string name="bnet_dl_client_first">Abra o Battle.net e entre uma vez; depois instale os jogos dele aqui.</string>
|
||||
<string name="bnet_dl_failed">O downloader da Blizzard parou: %1$s</string>
|
||||
<string name="bnet_dl_stalled">O downloader da Blizzard parou de avançar.</string>
|
||||
<string name="bnet_dl_agent_error">Erro da Blizzard %1$s</string>
|
||||
<string name="bnet_update">Atualizar</string>
|
||||
<string name="bnet_store">Jogos da Blizzard</string>
|
||||
|
||||
@@ -2527,6 +2527,7 @@
|
||||
<string name="bnet_dl_queued">Se așteaptă cealaltă descărcare Battle.net…</string>
|
||||
<string name="bnet_dl_client_first">Deschide Battle.net și conectează-te o dată, apoi instalează jocurile de aici.</string>
|
||||
<string name="bnet_dl_failed">Programul de descărcare Blizzard s-a oprit: %1$s</string>
|
||||
<string name="bnet_dl_stalled">Programul de descărcare Blizzard nu mai avansează.</string>
|
||||
<string name="bnet_dl_agent_error">Eroare Blizzard %1$s</string>
|
||||
<string name="bnet_update">Actualizează</string>
|
||||
<string name="bnet_store">Jocuri Blizzard</string>
|
||||
|
||||
@@ -2553,6 +2553,7 @@
|
||||
<string name="bnet_dl_queued">Ожидание другой загрузки Battle.net…</string>
|
||||
<string name="bnet_dl_client_first">Откройте Battle.net и войдите один раз, затем устанавливайте его игры здесь.</string>
|
||||
<string name="bnet_dl_failed">Загрузчик Blizzard остановился: %1$s</string>
|
||||
<string name="bnet_dl_stalled">Загрузчик Blizzard перестал продвигаться.</string>
|
||||
<string name="bnet_dl_agent_error">Ошибка Blizzard %1$s</string>
|
||||
<string name="bnet_update">Обновить</string>
|
||||
<string name="bnet_store">Игры Blizzard</string>
|
||||
|
||||
@@ -2501,6 +2501,7 @@
|
||||
<string name="bnet_dl_queued">Väntar på den andra Battle.net-nedladdningen…</string>
|
||||
<string name="bnet_dl_client_first">Öppna Battle.net och logga in en gång, installera sedan dess spel här.</string>
|
||||
<string name="bnet_dl_failed">Blizzards nedladdare stoppades: %1$s</string>
|
||||
<string name="bnet_dl_stalled">Blizzards nedladdare slutade göra framsteg.</string>
|
||||
<string name="bnet_dl_agent_error">Blizzard-fel %1$s</string>
|
||||
<string name="bnet_update">Uppdatera</string>
|
||||
<string name="bnet_store">Blizzard-spel</string>
|
||||
|
||||
@@ -2476,6 +2476,7 @@
|
||||
<string name="bnet_dl_queued">กำลังรอการดาวน์โหลด Battle.net อีกรายการ…</string>
|
||||
<string name="bnet_dl_client_first">เปิด Battle.net และลงชื่อเข้าใช้หนึ่งครั้ง แล้วติดตั้งเกมจากที่นี่</string>
|
||||
<string name="bnet_dl_failed">ตัวดาวน์โหลดของ Blizzard หยุดทำงาน: %1$s</string>
|
||||
<string name="bnet_dl_stalled">ตัวดาวน์โหลดของ Blizzard ไม่คืบหน้า</string>
|
||||
<string name="bnet_dl_agent_error">ข้อผิดพลาดของ Blizzard %1$s</string>
|
||||
<string name="bnet_update">อัปเดต</string>
|
||||
<string name="bnet_store">เกมของ Blizzard</string>
|
||||
|
||||
@@ -2493,6 +2493,7 @@
|
||||
<string name="bnet_dl_queued">Diğer Battle.net indirmesi bekleniyor…</string>
|
||||
<string name="bnet_dl_client_first">Battle.net\'i açıp bir kez oturum açın, ardından oyunlarını buradan yükleyin.</string>
|
||||
<string name="bnet_dl_failed">Blizzard indiricisi durdu: %1$s</string>
|
||||
<string name="bnet_dl_stalled">Blizzard indiricisi ilerlemeyi durdurdu.</string>
|
||||
<string name="bnet_dl_agent_error">Blizzard hatası %1$s</string>
|
||||
<string name="bnet_update">Güncelle</string>
|
||||
<string name="bnet_store">Blizzard oyunları</string>
|
||||
|
||||
@@ -2553,6 +2553,7 @@
|
||||
<string name="bnet_dl_queued">Очікування іншого завантаження Battle.net…</string>
|
||||
<string name="bnet_dl_client_first">Відкрийте Battle.net і увійдіть один раз, потім встановлюйте його ігри тут.</string>
|
||||
<string name="bnet_dl_failed">Завантажувач Blizzard зупинився: %1$s</string>
|
||||
<string name="bnet_dl_stalled">Завантажувач Blizzard перестав просуватися.</string>
|
||||
<string name="bnet_dl_agent_error">Помилка Blizzard %1$s</string>
|
||||
<string name="bnet_update">Оновити</string>
|
||||
<string name="bnet_store">Ігри Blizzard</string>
|
||||
|
||||
@@ -2476,6 +2476,7 @@
|
||||
<string name="bnet_dl_queued">Đang chờ lượt tải Battle.net khác…</string>
|
||||
<string name="bnet_dl_client_first">Mở Battle.net và đăng nhập một lần, sau đó cài trò chơi của nó tại đây.</string>
|
||||
<string name="bnet_dl_failed">Trình tải xuống của Blizzard đã dừng: %1$s</string>
|
||||
<string name="bnet_dl_stalled">Trình tải xuống của Blizzard không còn tiến triển.</string>
|
||||
<string name="bnet_dl_agent_error">Lỗi Blizzard %1$s</string>
|
||||
<string name="bnet_update">Cập nhật</string>
|
||||
<string name="bnet_store">Trò chơi Blizzard</string>
|
||||
|
||||
@@ -2553,6 +2553,7 @@
|
||||
<string name="bnet_dl_queued">正在等待另一个 Battle.net 下载…</string>
|
||||
<string name="bnet_dl_client_first">请先打开 Battle.net 并登录一次,然后在这里安装其游戏。</string>
|
||||
<string name="bnet_dl_failed">暴雪下载器已停止:%1$s</string>
|
||||
<string name="bnet_dl_stalled">暴雪下载器已停止进展。</string>
|
||||
<string name="bnet_dl_agent_error">暴雪错误 %1$s</string>
|
||||
<string name="bnet_update">更新</string>
|
||||
<string name="bnet_store">暴雪游戏</string>
|
||||
|
||||
@@ -2473,6 +2473,7 @@
|
||||
<string name="bnet_dl_queued">正在等待另一個 Battle.net 下載…</string>
|
||||
<string name="bnet_dl_client_first">請先開啟 Battle.net 並登入一次,然後在這裡安裝其遊戲。</string>
|
||||
<string name="bnet_dl_failed">暴雪下載器已停止:%1$s</string>
|
||||
<string name="bnet_dl_stalled">暴雪下載器已停止進展。</string>
|
||||
<string name="bnet_dl_agent_error">暴雪錯誤 %1$s</string>
|
||||
<string name="bnet_update">更新</string>
|
||||
<string name="bnet_store">Blizzard 遊戲</string>
|
||||
|
||||
@@ -2473,6 +2473,7 @@
|
||||
<string name="bnet_dl_queued">正在等待另一個 Battle.net 下載…</string>
|
||||
<string name="bnet_dl_client_first">請先開啟 Battle.net 並登入一次,然後在這裡安裝其遊戲。</string>
|
||||
<string name="bnet_dl_failed">暴雪下載器已停止:%1$s</string>
|
||||
<string name="bnet_dl_stalled">暴雪下載器已停止進度。</string>
|
||||
<string name="bnet_dl_agent_error">暴雪錯誤 %1$s</string>
|
||||
<string name="bnet_update">更新</string>
|
||||
<string name="bnet_store">Blizzard 遊戲</string>
|
||||
|
||||
@@ -2636,6 +2636,7 @@
|
||||
<string name="bnet_dl_queued">Waiting for the other Battle.net download…</string>
|
||||
<string name="bnet_dl_client_first">Open Battle.net and sign in once, then install its games here.</string>
|
||||
<string name="bnet_dl_failed">Blizzard\'s downloader stopped: %1$s</string>
|
||||
<string name="bnet_dl_stalled">Blizzard\'s downloader stopped making progress.</string>
|
||||
<string name="bnet_dl_agent_error">Blizzard error %1$s</string>
|
||||
<string name="bnet_update">Update</string>
|
||||
<string name="bnet_store">Blizzard games</string>
|
||||
|
||||
@@ -2,12 +2,15 @@ package com.droiddeck.launcher.stores.battlenet
|
||||
|
||||
import com.droiddeck.launcher.runtime.BattleNet
|
||||
import com.droiddeck.launcher.stores.CatalogItem
|
||||
import com.droiddeck.launcher.stores.InstalledStoreGame
|
||||
import com.droiddeck.launcher.stores.Store
|
||||
import com.droiddeck.launcher.stores.StoreGameSidecar
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
import java.util.Locale
|
||||
|
||||
@@ -89,4 +92,13 @@ class BattleNetInstallTest {
|
||||
assertEquals(BattleNetInstall.Step.APPLYING, BattleNetInstall.step(1003, 2000, 1, 9))
|
||||
assertEquals(BattleNetInstall.Step.APPLYING, BattleNetInstall.step(1004, 1000, 0, 0))
|
||||
}
|
||||
|
||||
@Test fun aSavedUpdateComesBackAsAnUpdateOfItsOwnFolder() {
|
||||
val folder = File("/data/Games/Stores/Battle.net/World of Warcraft")
|
||||
val game = InstalledStoreGame(StoreGameSidecar(Store.BATTLENET, "wow", "World of Warcraft", "Wow.exe"), folder)
|
||||
val item = BattleNetInstall.updateItem(game, "wow_enus")
|
||||
assertEquals("wow_enus", item.extra[BattleNetInstall.INSTALL_UID])
|
||||
assertEquals(folder, BattleNetInstall.updateFolder(item))
|
||||
assertNull(BattleNetInstall.updateFolder(CatalogItem(Store.BATTLENET, "wow", "World of Warcraft", null)))
|
||||
}
|
||||
}
|
||||
@@ -88,6 +88,8 @@ COUNTRY = re.compile(r"[A-Z]{3}")
|
||||
REGION = re.compile(r"[A-Z]{2}")
|
||||
REPORT = "BNET"
|
||||
ETA_LIMIT = 30 * 86400
|
||||
STALL = 600
|
||||
MOVING = ("download_current", "download_total", "progress", "playable_progress", "state", "phase", "paused", "error")
|
||||
DONE_STATE = 1004
|
||||
REPORTED = ("progress", "playable_progress", "download_rate", "download_remaining", "estimated_time_in_sec", "state",
|
||||
"playable", "paused", "download_complete", "installed", "error")
|
||||
@@ -118,6 +120,12 @@ function field(text, name) {
|
||||
return m ? m[1] : "";
|
||||
}
|
||||
|
||||
function job(text) {
|
||||
if (/"error"\s*:\s*[1-9]/.test(text)) return false;
|
||||
var bare = text.replace(/"extended_status"\s*:\s*\{[^}]*\}/, "");
|
||||
return /"state"\s*:\s*\d+/.test(bare) || /"download_current"\s*:/.test(bare);
|
||||
}
|
||||
|
||||
function install() {
|
||||
// Blizzard's China repository moved to cn.patch.battlenet.com.cn; cn.patch.battle.net only redirects away from it.
|
||||
var patch = zone == "cn" ? "cn.patch.battlenet.com.cn" : zone + ".patch.battle.net";
|
||||
@@ -140,7 +148,7 @@ function watch(path) {
|
||||
if (/"error"\s*:\s*[1-9]/.test(s)) break;
|
||||
var state = /"state"\s*:\s*(\d+)/.exec(s.replace(/"extended_status"\s*:\s*\{[^}]*\}/, "")), complete = /"download_complete"\s*:\s*true/.test(s);
|
||||
state = state ? +state[1] : 0;
|
||||
if (state == 1000 || state == 1003 || !complete) started = true;
|
||||
if (state == 1000 || state == 1003 || job(s) && !complete) started = true;
|
||||
if (started && (state == 1004 || complete && /"playable"\s*:\s*true/.test(s))) break;
|
||||
if (!started && state == 1004 && i >= 20) break;
|
||||
if (!started && i >= 180) {
|
||||
@@ -1376,7 +1384,7 @@ def summary(status):
|
||||
return out
|
||||
|
||||
|
||||
def agent_job(root, action, uid, product="", folder="", locale="enUS", country="USA", region="US", poll=None, wait=None):
|
||||
def agent_job(root, action, uid, product="", folder="", locale="enUS", country="USA", region="US", poll=None, wait=None, stall=None):
|
||||
pfx = os.path.join(prefix(root), "pfx")
|
||||
if not installed(root) or agent_exe(root) is None:
|
||||
emit("ERROR", "client")
|
||||
@@ -1432,6 +1440,7 @@ def agent_job(root, action, uid, product="", folder="", locale="enUS", country="
|
||||
os.replace(output, output + ".1")
|
||||
except OSError:
|
||||
pass
|
||||
before = {pid for pid, _ in wine_processes(pfx)}
|
||||
with open(output, "ab") as log:
|
||||
try:
|
||||
child = subprocess.Popen(cmd, stdin=subprocess.DEVNULL, stdout=log, stderr=log, env=env)
|
||||
@@ -1439,6 +1448,9 @@ def agent_job(root, action, uid, product="", folder="", locale="enUS", country="
|
||||
emit("ERROR", "stopped gamescope: %s" % error)
|
||||
return 1
|
||||
seen = None
|
||||
mark = None
|
||||
moved = time.monotonic()
|
||||
stalled = False
|
||||
while True:
|
||||
done = child.poll() is not None
|
||||
status = read_status(base + ".json")
|
||||
@@ -1447,12 +1459,27 @@ def agent_job(root, action, uid, product="", folder="", locale="enUS", country="
|
||||
if brief != seen:
|
||||
emit("PROGRESS", json.dumps(brief, sort_keys=True))
|
||||
seen = brief
|
||||
signature = tuple(brief.get(key) for key in MOVING)
|
||||
if signature != mark:
|
||||
mark = signature
|
||||
moved = time.monotonic()
|
||||
if done:
|
||||
break
|
||||
if action != "uninstall" and time.monotonic() - moved > (STALL if stall is None else stall):
|
||||
say("the %s of %s made no progress for %d s; stopping it" % (action, uid, STALL if stall is None else stall))
|
||||
stalled = True
|
||||
child.kill()
|
||||
child.wait()
|
||||
break
|
||||
time.sleep(POLL if poll is None else poll)
|
||||
leftovers = wine_processes(pfx)
|
||||
if leftovers and idle(leftovers):
|
||||
stop(leftovers)
|
||||
elif stalled:
|
||||
stop([(pid, argv) for pid, argv in leftovers if pid not in before and program(argv) == AGENT])
|
||||
if stalled:
|
||||
emit("ERROR", "stalled")
|
||||
return 6
|
||||
answer = read_status(base + ".game")
|
||||
game = answer or {}
|
||||
status = read_status(base + ".json") or {}
|
||||
|
||||
@@ -1441,6 +1441,138 @@ class AgentJobTest(Harness):
|
||||
self.assertEqual(BNET["agent_job"](self.root, "update", "gryphon", poll=0), 1)
|
||||
self.assertEqual(self.lines[-1][0], "ERROR")
|
||||
|
||||
def test_a_job_that_stops_moving_is_ended_as_stalled_and_its_agent_stopped(self):
|
||||
self.install()
|
||||
self.files = {".json": json.dumps({"state": 1003, "paused": True, "download_current": [10, 0, 0], "download_total": [99, 0, 0]})}
|
||||
killed = []
|
||||
stopped = []
|
||||
|
||||
class Hung:
|
||||
returncode = None
|
||||
|
||||
def __init__(self, cmd, **kwargs):
|
||||
base = cmd[-1][2:].replace("\\", "/")
|
||||
with open(base + ".json", "wb") as f:
|
||||
f.write(self_files[".json"].encode("utf-16"))
|
||||
|
||||
def poll(self):
|
||||
return None
|
||||
|
||||
def kill(self):
|
||||
killed.append(True)
|
||||
|
||||
def wait(self):
|
||||
return -9
|
||||
|
||||
self_files = self.files
|
||||
with mock.patch.object(BNET["subprocess"], "Popen", Hung), \
|
||||
mock.patch.dict(BNET, {"wine_processes": lambda pfx: [(5, ["agent.exe"])], "stop": lambda p: stopped.append(p)}):
|
||||
code = BNET["agent_job"](self.root, "install", "s1", "s1", str(self.tmp / "S1"), "enUS", "USA", "US", poll=0, stall=0.05)
|
||||
self.assertEqual(code, 6)
|
||||
self.assertEqual(killed, [True])
|
||||
self.assertEqual(stopped, [[(5, ["agent.exe"])]])
|
||||
self.assertEqual(self.lines[-1], ("ERROR", "stalled"))
|
||||
|
||||
def test_a_stalled_job_leaves_a_game_or_client_in_the_prefix_running(self):
|
||||
self.install()
|
||||
self.files = {".json": json.dumps({"state": 1003, "download_current": [10, 0, 0], "download_total": [99, 0, 0]})}
|
||||
stopped = []
|
||||
calls = []
|
||||
|
||||
class Hung:
|
||||
returncode = None
|
||||
|
||||
def __init__(self, cmd, **kwargs):
|
||||
calls.append(True)
|
||||
|
||||
def poll(self):
|
||||
return None
|
||||
|
||||
def kill(self):
|
||||
pass
|
||||
|
||||
def wait(self):
|
||||
return -9
|
||||
|
||||
def processes(pfx):
|
||||
if not calls:
|
||||
return [(3, ["agent.exe"])]
|
||||
return [(3, ["agent.exe"]), (5, ["Agent.exe"]), (6, ["wineserver"]), (7, ["Wow.exe"])]
|
||||
|
||||
with mock.patch.object(BNET["subprocess"], "Popen", Hung), \
|
||||
mock.patch.dict(BNET, {"wine_processes": processes, "stop": lambda p: stopped.append(p)}):
|
||||
code = BNET["agent_job"](self.root, "install", "s1", "s1", str(self.tmp / "S1"), "enUS", "USA", "US", poll=0, stall=0.05)
|
||||
self.assertEqual(code, 6)
|
||||
self.assertEqual(stopped, [[(5, ["Agent.exe"])]])
|
||||
|
||||
def test_only_a_changing_rate_or_estimate_does_not_hold_off_the_stall(self):
|
||||
self.install()
|
||||
clock = [0.0]
|
||||
|
||||
class Spinning:
|
||||
returncode = None
|
||||
|
||||
def __init__(self, cmd, **kwargs):
|
||||
self.base = cmd[-1][2:].replace("\\", "/")
|
||||
self.polls = 0
|
||||
|
||||
def poll(self):
|
||||
self.polls += 1
|
||||
if self.polls > 10:
|
||||
raise AssertionError("the stall timeout never ended the job")
|
||||
clock[0] += 10
|
||||
with open(self.base + ".json", "wb") as f:
|
||||
f.write(json.dumps({"state": 1003, "download_current": [4, 0, 0], "download_total": [9, 0, 0],
|
||||
"download_rate": self.polls, "estimated_time_in_sec": self.polls}).encode("utf-16"))
|
||||
return None
|
||||
|
||||
def kill(self):
|
||||
pass
|
||||
|
||||
def wait(self):
|
||||
return -9
|
||||
|
||||
fake = mock.Mock(monotonic=lambda: clock[0], sleep=lambda s: None)
|
||||
with mock.patch.object(BNET["subprocess"], "Popen", Spinning), mock.patch.dict(BNET, {"time": fake, "stop": lambda p: None}):
|
||||
code = BNET["agent_job"](self.root, "update", "gryphon", poll=0, stall=25)
|
||||
self.assertEqual(code, 6)
|
||||
self.assertEqual(self.lines[-1], ("ERROR", "stalled"))
|
||||
|
||||
def test_a_moving_job_is_not_ended_as_stalled(self):
|
||||
self.install()
|
||||
done = json.dumps({"installed": True, "playable": True, "install_dir": "Z:/g", "local_version": "2"})
|
||||
clock = [0.0]
|
||||
|
||||
class Moving:
|
||||
returncode = 0
|
||||
|
||||
def __init__(self, cmd, **kwargs):
|
||||
self.base = cmd[-1][2:].replace("\\", "/")
|
||||
self.polls = 0
|
||||
|
||||
def poll(self):
|
||||
self.polls += 1
|
||||
clock[0] += 10
|
||||
with open(self.base + ".json", "wb") as f:
|
||||
f.write(json.dumps({"state": 1003, "download_current": [self.polls, 0, 0], "download_total": [9, 0, 0]}).encode("utf-16"))
|
||||
if self.polls < 6:
|
||||
return None
|
||||
with open(self.base + ".game", "wb") as f:
|
||||
f.write(done.encode("utf-16"))
|
||||
return 0
|
||||
|
||||
fake = mock.Mock(monotonic=lambda: clock[0], sleep=lambda s: None)
|
||||
with mock.patch.object(BNET["subprocess"], "Popen", Moving), mock.patch.dict(BNET, {"time": fake}):
|
||||
code = BNET["agent_job"](self.root, "update", "gryphon", poll=0, stall=15)
|
||||
self.assertEqual(code, 0)
|
||||
self.assertNotIn(("ERROR", "stalled"), self.lines)
|
||||
|
||||
def test_only_a_real_job_reply_counts_as_started(self):
|
||||
script = BNET["AGENT_SCRIPT"]
|
||||
self.assertIn("if (state == 1000 || state == 1003 || job(s) && !complete) started = true;", script)
|
||||
self.assertIn('return /"state"\\s*:\\s*\\d+/.test(bare) || /"download_current"\\s*:/.test(bare);', script)
|
||||
self.assertIn('if (/"error"\\s*:\\s*[1-9]/.test(text)) return false;', script)
|
||||
|
||||
def test_the_driver_only_stops_once_the_agent_has_really_run(self):
|
||||
script = BNET["AGENT_SCRIPT"]
|
||||
self.assertIn("if (started && (state == 1004 || complete && /\"playable\"\\s*:\\s*true/.test(s))) break;", script)
|
||||
|
||||
Reference in new issue
Block a user