diff --git a/install.py b/install.py index 715771444..2a3e78e73 100644 --- a/install.py +++ b/install.py @@ -11347,10 +11347,23 @@ def _open_from_browser(state: TuiState) -> list[tuple]: state.browse_for = "from" _push(state, "browse") start = state.from_folders[-1].parent if state.from_folders else state.home + downloads = state.home / "Downloads" + if not state.from_folders and _is_dir(downloads) and any( + name.lower().endswith(".zip") for name in _listed(downloads)): + # A pack or a backup ZIP is most often there: 18 presses from the + # first screen reached it through HOME, past every mounted drive. + start = downloads _browse_to(state, _nearest_folder(start)) return [] +def _listed(folder: Path) -> list[str]: + try: + return os.listdir(folder) + except OSError: + return [] + + def _toggle_region(state: TuiState, name: str) -> None: if name in state.regions: state.regions.remove(name) diff --git a/tests/test_install_tui.py b/tests/test_install_tui.py index 1d5dd4086..4c8f1e9c1 100644 --- a/tests/test_install_tui.py +++ b/tests/test_install_tui.py @@ -3962,6 +3962,25 @@ class TheHelpNamesKeysThatCome(unittest.TestCase): self.assertTrue(any("A, Start, Enter, Space, x Choose" in line for line in lines)) +class CopyFromStartsInDownloads(unittest.TestCase): + """A ZIP in Downloads took 18 presses from the first screen: the copy + browser opened at HOME, under every mounted drive.""" + + def test_a_zip_in_downloads_opens_there(self): + home = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp")) + self.addCleanup(shutil.rmtree, home, True) + (home / "Downloads").mkdir() + state = checked_state() + state.home = home + with mock.patch.object(install, "_mounted_cards", return_value=[]): + install._open_from_browser(state) + self.assertEqual(state.browse_dir, home) + state.stack.pop() + (home / "Downloads" / "PSX BIOS.zip").write_bytes(b"") + install._open_from_browser(state) + self.assertEqual(state.browse_dir, home / "Downloads") + + class NothingFoundIsSaid(unittest.TestCase): """With nothing detected the first screen was the list of 18 setups, with no line at 40x15 saying nothing was found, which the beginner's