mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-23 06:46:02 +00:00
fix: refresh repaired components and render Ubisoft Connect (#2090)
* fix: refresh repaired components and render Ubisoft Connect * fix: address component repair and Wine registry review * fix: repair manually enabled components and check registry writes * fix: serialize component repairs and use Proton runinprefix * fix: report queued component repair failures * fix: preserve newer component repair waits * Make component queue transitions atomic * Isolate component apply failures by game * Preserve pending repair when catalog is stale * Restore persisted component repair revisions * Update pending requirements atomically * Respect disabled pending components per game * Keep queue key state atomic while worker waits * Pass selected game to component repairs * Preserve pending repair when component is absent * Preserve pending revision on catalog failure * Test legacy pending repair revision recovery * Isolate fake worker Steam app info lookup * Merge queued Steam app info lookups * Persist launch component revisions before repair * Gate launch on component repair discovery * Expand and refresh launch repair discovery * Include new automatic picks in launch requirements * Log repair persistence failures and align repair keys * Use runtime key for Battle.net component repairs * Retain failed component reapplications for retry * Harden pending repairs and launch preparation * Isolate wait-cool sleep mocking * Allow launches without catalog when no repair is pending * Queue launch repairs even if persistence fails * Block launch when repair state cannot persist * Allow launch when no component repair is needed * Persist selected repairs when catalog is offline * Drain offline component repair in test
This commit is contained in:
1 parent
ab92033b90
commit
516e3862fa
14 files changed
+756
-83
No files matched your search
@@ -490,7 +490,7 @@ class DroiddeckctlTest(FakeAdbTest):
|
||||
|
||||
def test_wait_cool_polls_until_the_battery_is_below(self):
|
||||
self.configure({}, battery=[battery(412), battery(395), battery(379)], thermalservice=THERMALSERVICE)
|
||||
with unittest.mock.patch.object(ctl.time, "sleep") as slept:
|
||||
with unittest.mock.patch.object(ctl, "wait_sleep") as slept:
|
||||
code, out = self.run_ctl("wait", "cool", "--below", "38", "--timeout", "600")
|
||||
self.assertEqual(0, code, out)
|
||||
self.assertEqual(["wait", 37.9], [out["command"], out["batteryC"]])
|
||||
|
||||
@@ -2190,6 +2190,66 @@ class UbisoftOverlayTest(unittest.TestCase):
|
||||
self.assertEqual(sorted(p.name for p in settings.parent.iterdir()), ["settings.yaml"])
|
||||
|
||||
|
||||
class UbisoftCompositionTest(unittest.TestCase):
|
||||
def test_writes_through_wine_without_replacing_a_live_servers_registry(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
prefix = Path(tmp) / "pfx"
|
||||
(prefix / MODULE["UBISOFT_LAUNCHER"]).mkdir(parents=True)
|
||||
registry = prefix / "user.reg"
|
||||
registry.write_text("registry last saved by Wine\n")
|
||||
env = {"STEAM_COMPAT_DATA_PATH": tmp, "WINESERVER": "/selected/wineserver"}
|
||||
keys = []
|
||||
|
||||
def write_registry(argv, **kwargs):
|
||||
self.assertEqual(argv[:4], ["/selected/proton", "runinprefix", "reg.exe", "add"])
|
||||
self.assertEqual(argv[5:], ["/v", "dcomp", "/t", "REG_SZ", "/d", "", "/f"])
|
||||
self.assertIs(kwargs["env"], env)
|
||||
self.assertTrue(kwargs["check"])
|
||||
keys.append(argv[4])
|
||||
registry.write_text("newer state saved by the active Wine server\n")
|
||||
return subprocess.CompletedProcess(argv, 0)
|
||||
|
||||
with mock.patch("subprocess.run", side_effect=write_registry) as run:
|
||||
MODULE["ubisoft_composition_off"]("/selected/proton", env)
|
||||
self.assertEqual(run.call_count, 2)
|
||||
self.assertEqual(registry.read_text(), "newer state saved by the active Wine server\n")
|
||||
self.assertEqual(keys, [r"HKCU\Software\Wine\AppDefaults\%s\DllOverrides" % program
|
||||
for program in ("upc.exe", "UplayWebCore.exe")])
|
||||
self.assertEqual(list(prefix.glob(".ubisoft-*.reg")), [])
|
||||
|
||||
def test_other_prefixes_and_uninitialized_registries_are_untouched(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
prefix = Path(tmp) / "pfx"
|
||||
prefix.mkdir()
|
||||
registry = prefix / "user.reg"
|
||||
registry.write_text("WINE REGISTRY Version 2\n")
|
||||
env = {"STEAM_COMPAT_DATA_PATH": tmp}
|
||||
with mock.patch("subprocess.run") as run:
|
||||
MODULE["ubisoft_composition_off"]("proton", env)
|
||||
self.assertEqual(registry.read_text(), "WINE REGISTRY Version 2\n")
|
||||
registry.unlink()
|
||||
(prefix / MODULE["UBISOFT_LAUNCHER"]).mkdir(parents=True)
|
||||
MODULE["ubisoft_composition_off"]("proton", env)
|
||||
self.assertFalse(registry.exists())
|
||||
run.assert_not_called()
|
||||
|
||||
def test_failed_registry_write_keeps_the_game_launch_available(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
prefix = Path(tmp) / "pfx"
|
||||
(prefix / MODULE["UBISOFT_LAUNCHER"]).mkdir(parents=True)
|
||||
(prefix / "user.reg").write_text("WINE REGISTRY Version 2\n")
|
||||
for failed_write in (0, 1):
|
||||
stderr = io.StringIO()
|
||||
results = [subprocess.CompletedProcess([], 0)] * failed_write
|
||||
results.append(subprocess.CalledProcessError(1, "proton"))
|
||||
with mock.patch("subprocess.run", side_effect=results) as run, mock.patch("sys.stderr", stderr):
|
||||
MODULE["ubisoft_composition_off"]("proton", {"STEAM_COMPAT_DATA_PATH": tmp})
|
||||
self.assertEqual(run.call_count, failed_write + 1)
|
||||
self.assertIn("configuration failed", stderr.getvalue())
|
||||
self.assertNotIn("uses CEF", stderr.getvalue())
|
||||
self.assertEqual(list(prefix.glob(".ubisoft-*.reg")), [])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
|
||||
@@ -274,10 +274,13 @@ class PendingWaitTest(unittest.TestCase):
|
||||
def tearDown(self):
|
||||
self.tmp.cleanup()
|
||||
|
||||
def install(self, cid):
|
||||
def install(self, cid, revision=0):
|
||||
folder = self.store / cid
|
||||
folder.mkdir(parents=True, exist_ok=True)
|
||||
(folder / "component.json").write_text(json.dumps({"id": cid, "overrides": []}))
|
||||
metadata = {"id": cid, "overrides": []}
|
||||
if revision is not None:
|
||||
metadata["revision"] = revision
|
||||
(folder / "component.json").write_text(json.dumps(metadata))
|
||||
|
||||
def clock(self):
|
||||
return len(self.slept) * 0.5
|
||||
@@ -296,6 +299,8 @@ class PendingWaitTest(unittest.TestCase):
|
||||
self.install("d3dx9")
|
||||
self.pending.write_text(json.dumps({"games": {"1262580": ["d3dx9"]}}))
|
||||
self.assertIsNone(self.wait())
|
||||
self.install("d3dx9", revision=None)
|
||||
self.assertIsNone(self.wait())
|
||||
self.assertEqual([], self.slept)
|
||||
|
||||
def test_waits_until_the_component_lands(self):
|
||||
@@ -311,6 +316,21 @@ class PendingWaitTest(unittest.TestCase):
|
||||
self.assertEqual(4, len(self.slept))
|
||||
self.assertEqual("wincomp: 1262580 launched without vcredist2019_dll (not ready)", note)
|
||||
|
||||
def test_an_existing_old_revision_waits_until_the_repair_lands(self):
|
||||
self.install("vcredist2010_dll", revision=0)
|
||||
self.pending.write_text(json.dumps({"games": {"1262580": ["vcredist2010_dll"]},
|
||||
"revisions": {"vcredist2010_dll": 1}}))
|
||||
note = self.wait(on_sleep=lambda n: self.install("vcredist2010_dll", revision=1) if n == 3 else None)
|
||||
self.assertEqual(3, len(self.slept))
|
||||
self.assertEqual(note, "wincomp: 1262580 waited 1500ms for vcredist2010_dll")
|
||||
|
||||
def test_an_old_revision_does_not_satisfy_a_pending_repair(self):
|
||||
self.install("vcredist2010_dll", revision=1)
|
||||
self.pending.write_text(json.dumps({"games": {"1262580": ["vcredist2010_dll"]},
|
||||
"revisions": {"vcredist2010_dll": 2}}))
|
||||
self.assertEqual(self.wait(timeout=1.0), "wincomp: 1262580 launched without vcredist2010_dll (not ready)")
|
||||
self.assertEqual(2, len(self.slept))
|
||||
|
||||
def test_a_damaged_pending_file_is_no_wait(self):
|
||||
self.pending.write_text("{not json")
|
||||
self.assertIsNone(self.wait())
|
||||
|
||||
Reference in new issue
Block a user