fix: open the copy browser at a zip in downloads

This commit is contained in:
Abdessamad Derraz committed 2026-10-26 21:19:26 +01:00
1 parent ae3faec86b
commit ad60a88deb
2 files changed
+32

No files matched your search

+13
View File
@@ -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)
+19
View File
@@ -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