fix: take the Agent's empty answer for an uninstalled game as gone

Once Blizzard's Agent has removed a game it answers GET /game/<uid> with
an empty object, not installed false, so a finished uninstall read as a
failure and opened Battle.net.
This commit is contained in:
maxjivi05 authored and MaxsTechReview committed 2026-10-26 09:01:02 -04:00
1 parent c48297e0d1
commit 3b6b304f55
2 files changed
+6 -2

No files matched your search

@@ -1227,7 +1227,8 @@ def agent_job(root, action, uid, product="", folder="", locale="enUS", country="
leftovers = wine_processes(pfx)
if leftovers and idle(leftovers):
stop(leftovers)
game = read_status(base + ".game") or {}
answer = read_status(base + ".game")
game = answer or {}
status = read_status(base + ".json") or {}
try:
with open(base + ".error", "rb") as f:
@@ -1248,7 +1249,7 @@ def agent_job(root, action, uid, product="", folder="", locale="enUS", country="
"version": game.get("local_version", "")}, sort_keys=True))
say("%s %s in %s" % (uid, "updated" if action == "update" else "installed", game.get("install_dir", windows)))
return 0
if reason is None and action == "uninstall" and game.get("installed") is False:
if reason is None and action == "uninstall" and (game.get("installed") is False or answer == {}):
emit("DONE", json.dumps({"uninstalled": uid}))
say("%s uninstalled" % uid)
return 0
+3
View File
@@ -1210,6 +1210,9 @@ class AgentJobTest(Harness):
self.files = {".game": json.dumps({"error": 2})}
self.assertEqual(BNET["agent_job"](self.root, "uninstall", "gryphon", poll=0), 1)
self.assertEqual(self.lines[-1][0], "ERROR")
self.files = {".game": json.dumps({})}
self.assertEqual(BNET["agent_job"](self.root, "uninstall", "gryphon", poll=0), 0)
self.assertEqual(self.lines[-1], ("DONE", json.dumps({"uninstalled": "gryphon"})))
def test_without_battle_net_nothing_starts(self):
self.assertEqual(BNET["agent_job"](self.root, "install", "gryphon", "gryphon", str(self.tmp / "g"), "enUS", "USA", "US", poll=0), 3)