From fd33ad0d96ae517d15d1213402e0bdc6287055c6 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Sat, 24 Oct 2026 01:38:31 +0200 Subject: [PATCH] fix: let A go deeper from home or a drive root With no usual folder the browser opened at HOME on Use this folder, and A pressed through the screens installed the BIOS files into ~. At HOME or a drive's root A now opens the first folder. Picking the old card to copy from is unchanged. --- install.ps1 | 2 +- install.py | 6 ++++++ install.sh | 2 +- tests/test_install_tui.py | 20 ++++++++++++++++++++ 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/install.ps1 b/install.ps1 index 68776bf3..f599cefe 100644 --- a/install.ps1 +++ b/install.ps1 @@ -11,7 +11,7 @@ $ErrorActionPreference = "Stop" $defaultInstallUrl = "https://raw.githubusercontent.com/Abdess/retrobios/main/install.py" - $defaultInstallSha256 = "04070f071adf988291854cf4ad8fb6e7a34f8044cfbcb710ba660863c2c6b19e" + $defaultInstallSha256 = "23f334efb9e37ba1c2542b8599db7af6e67dfd5e0061d39cb507765f2594bd45" $maximumInstallerBytes = 2MB $installerExit = 0 $installer = if ($PSScriptRoot) { Join-Path $PSScriptRoot "install.py" } else { $null } diff --git a/install.py b/install.py index 0a81416f..41b98b62 100644 --- a/install.py +++ b/install.py @@ -10924,6 +10924,12 @@ def _browse_to(state: TuiState, folder: Path | None, came_from: Path | None = No state.browse_dir = folder state.browse_rows, state.status = _browse_rows(folder, state.browse_for == "from") focus = 0 + if (folder is not None and state.browse_for != "from" + and folder in (state.home, Path(folder.anchor))): + # No frontend reads its BIOS files from HOME or a drive's root: A + # pressed through the screens installed into ~. A goes deeper there. + focus = next((index for index, row in enumerate(state.browse_rows) + if row.action == "dir" and row.value != folder.parent), 0) for index, row in enumerate(state.browse_rows): if came_from is not None and row.action == "dir" and row.value == came_from: focus = index diff --git a/install.sh b/install.sh index 0dd9260a..b4b41cca 100755 --- a/install.sh +++ b/install.sh @@ -18,7 +18,7 @@ esac TEMP_INSTALLER="" TEMP_DIRECTORY="" DEFAULT_INSTALL_URL="https://raw.githubusercontent.com/Abdess/retrobios/main/install.py" -DEFAULT_INSTALL_SHA256="04070f071adf988291854cf4ad8fb6e7a34f8044cfbcb710ba660863c2c6b19e" +DEFAULT_INSTALL_SHA256="23f334efb9e37ba1c2542b8599db7af6e67dfd5e0061d39cb507765f2594bd45" MAX_INSTALLER_BYTES=2097152 cleanup() { diff --git a/tests/test_install_tui.py b/tests/test_install_tui.py index 64c6c3c3..1854d086 100644 --- a/tests/test_install_tui.py +++ b/tests/test_install_tui.py @@ -642,6 +642,26 @@ class Flow(unittest.TestCase): self.assertEqual(effects, [("fetch", "retroarch")]) self.assertEqual(state.dest, root) + def test_a_holds_no_bios_folder_root_never_takes_a(self): + """With no usual folder the browser opens at HOME, on Use this + folder: A five times installed the BIOS files into ~. At HOME or a + drive's root, A goes into the first folder instead.""" + home = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp")) + self.addCleanup(shutil.rmtree, home, True) + (home / "Games").mkdir() + state = install.TuiState(os_type="linux", home=home) + state.platform = "retroarch" + state.stack = ["folder"] + state.folder_default = None + with mock.patch.object(install, "_mounted_cards", return_value=[]): + install._browse_to(state, home) + self.assertEqual(state.browse_rows[state.focus["browse"]].label, "Games/") + install._browse_to(state, home / "Games") + self.assertEqual(state.browse_rows[state.focus["browse"]].label, + "Use this folder") + install._browse_to(state, Path(home.anchor)) + self.assertNotEqual(state.browse_rows[state.focus["browse"]].action, "use") + def test_cards_are_listed_first(self): card = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp")) self.addCleanup(shutil.rmtree, card, True)