From 73d6c8ffb8af5c26af34b2d7918eafacff417a56 Mon Sep 17 00:00:00 2001 From: chrg6 Date: Fri, 13 Nov 2026 17:19:54 -0500 Subject: [PATCH] Refuse the command line's update while the game runs, as the window's Updates row does. `launcher.cli update` downloaded the release and switched to it without asking whether the game ran. The new version's continue-update then failed in its rebuild with "the game is running", which left the new launcher with the old build until Rebuild the Game. The window's App.start_update refuses first; the command now does the same before its update check, and ends with exit code 1 and "error: the game is running: close it first, the update rebuilds it". Not reproduced before the change: found by reading the code. Checks that passed: tests/launcher_test.py (217 tests, a new one in which a running game stops `update` before its check and its download, which fails before the change) and tools/check_content.py --staged. Co-Authored-By: Claude Opus 5.5 --- launcher/cli.py | 6 ++++++ tests/launcher_test.py | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/launcher/cli.py b/launcher/cli.py index 91117b96..b9460a93 100644 --- a/launcher/cli.py +++ b/launcher/cli.py @@ -101,6 +101,12 @@ def run(a, ctx, held): return 0 if a.cmd == 'update': + # The new version rebuilds the game (ContinueUpdateJob), which cannot replace a running exe: refused here + # before anything is downloaded, as the window's Updates row refuses (ui/app.py App.start_update) + gd = s.get('game_dir') + if gd and build.game_running(gd): + print('error: the game is running: close it first, the update rebuilds it', file=sys.stderr) + return 1 check = jobs.CheckJob(ctx).run_inline() if check.result != 'ok' or not jobs.update_available(ctx, check.release): print(check.error or f'up to date: {ctx.version}') diff --git a/tests/launcher_test.py b/tests/launcher_test.py index cb05662d..907d75b2 100644 --- a/tests/launcher_test.py +++ b/tests/launcher_test.py @@ -4138,6 +4138,23 @@ class LockTest(Tmp): self.assertIn(f'error: the launcher window (process {other.pid}', err.getvalue()) self.assertIn('try again', err.getvalue()) + def test_the_command_line_update_refuses_while_the_game_runs(self): + """`update` rebuilds the game after it switched versions: started while the game runs, it would leave the new + version with the old build. It refuses before it downloads anything, as the window's Updates row does.""" + import argparse + from launcher import cli + ctx = mock.MagicMock() + ctx.settings = {'game_dir': str(self.tmp / 'game')} + err = io.StringIO() + with mock.patch('launcher.cli.build.game_running', return_value=True) as running, \ + mock.patch('launcher.cli.jobs.CheckJob') as check, \ + mock.patch('launcher.cli.jobs.UpdateDownloadJob') as download, contextlib.redirect_stderr(err): + self.assertEqual(cli.run(argparse.Namespace(cmd='update'), ctx, mock.MagicMock()), 1) + running.assert_called_once_with(str(self.tmp / 'game')) + check.assert_not_called() + download.assert_not_called() + self.assertIn('error: the game is running', err.getvalue()) + # ---------------------------------------------------------------- the icon