From dcf9dc00f59acb4c605b31e82cc6d0f2ea795a40 Mon Sep 17 00:00:00 2001 From: QIU SHENGMING Date: Thu, 1 Oct 2026 22:03:37 +0800 Subject: [PATCH] Keep what the page installed when the server restarts The page edits a working copy of the flash image on purpose -- the file it was first pointed at may be a real calibration dump -- but a restart pointed at a different image switched to that file's copy instead, and the games installed through the page looked like they had vanished (measured: the app table came back holding an older slot). work/run-webui.ps1 now prefers the working copy the page has been editing, ahead of the original, and the page's own hint says which image it is editing and that the loaded one is never modified. A test asserts the order in the script. --- tools/test_uvk5_supervisor.py | 20 ++++++++++++++++++++ tools/webui.py | 4 +++- work/run-webui.ps1 | 7 ++++++- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/tools/test_uvk5_supervisor.py b/tools/test_uvk5_supervisor.py index d416c7c..67a4a7e 100644 --- a/tools/test_uvk5_supervisor.py +++ b/tools/test_uvk5_supervisor.py @@ -299,3 +299,23 @@ class TestRecoversFromAnExternalKill(unittest.TestCase): if __name__ == "__main__": unittest.main() + + +class TestLauncherPrefersTheWorkingCopy(unittest.TestCase): + """A restart must not look like the page's installs vanished.""" + + def test_the_script_lists_the_working_copy_before_the_original(self): + import os as _os + path = _os.path.join(_os.path.dirname(_os.path.abspath(__file__)), + "..", "work", "run-webui.ps1") + if not _os.path.exists(path): + self.skipTest("work/run-webui.ps1 is not in this checkout") + with open(path, encoding="utf-8") as fh: + text = fh.read() + # the working copy the page edits comes before the file it was first pointed at + working = text.find("work\\firmware\\flash-current.img") + original = text.find("work\\user-flash.img") + self.assertNotEqual(working, -1, "the working copy is not in the list") + self.assertNotEqual(original, -1) + self.assertLess(working, original, + "a restart would fall back to the original image") diff --git a/tools/webui.py b/tools/webui.py index 49732a7..5448225 100644 --- a/tools/webui.py +++ b/tools/webui.py @@ -975,7 +975,9 @@ def render_index(scale: int) -> str:
the multi-system slots live in the external flash; - write a .bin into one, then press Multiboot + write a .bin into one, then press Multiboot. Edits go to a working copy of the image + (the file named above), so the one you loaded is never modified — and a restart keeps + that copy rather than reverting to the original
diff --git a/work/run-webui.ps1 b/work/run-webui.ps1 index 29b33f6..52f3475 100644 --- a/work/run-webui.ps1 +++ b/work/run-webui.ps1 @@ -46,7 +46,12 @@ if ($Status) { $common += @('--status-addr', $Status) } if (-not $Kernel -and $env:ELF) { $Kernel = $env:ELF } if (-not $Flash) { - $candidates = @($env:UVK5_FLASH_IMAGE, 'work\user-flash.img', 'assets\flash.img') + # The page edits a working copy (webui copies the image before its first write, so a + # real calibration dump is never touched). Preferring it here means a restart keeps + # whatever was installed through the page, instead of silently falling back to the + # file it was first pointed at and looking like the install vanished. + $candidates = @($env:UVK5_FLASH_IMAGE, 'work\firmware\flash-current.img', + 'work\user-flash.img', 'assets\flash.img') foreach ($candidate in $candidates) { if ($candidate -and (Test-Path $candidate)) { $Flash = $candidate; break } }