Skip to content

feat(extract): auto-detect next disc, drop double confirmation#26

Merged
Xitee1 merged 1 commit into
mainfrom
feat/extract-auto-detect-disc
May 19, 2026
Merged

feat(extract): auto-detect next disc, drop double confirmation#26
Xitee1 merged 1 commit into
mainfrom
feat/extract-auto-detect-disc

Conversation

@Xitee1
Copy link
Copy Markdown
Owner

@Xitee1 Xitee1 commented May 18, 2026

Summary

  • Discs ≥ 2 are detected automatically by polling drive_status (CDROM ioctl). No more prompt_yn(\"Insert another disc?\") + prompt_disc(\"Insert disc N\") per transition.
  • Single-keypress e (via termios cbreak on stdin, no Enter needed) signals "done collecting, proceed to extract" — replaces the trailing Y/n confirmation.
  • Disc 1 keeps the classic Press Enter when ready prompt so the user can read the header info before the run starts.

Implementation

  • New src/bd_archive/ui/keypress.py: cbreak_stdin() context manager (saves/restores tcgetattr, no-op on non-TTY) + read_keypress(timeout) (select-based, lowercased single char or None).
  • New _wait_for_next_disc(dio, mount_dir, target) in commands/extract.py: polls drive + stdin every 300 ms, renders a Braille spinner on TTY stdout. Returns mount path on disc detect, None on e.
  • Wrong-chain / unparseable disc → existing continue path runs the finally (umount + eject) and the next iteration re-enters the wait. No new validation logic.
  • _mount_with_prompt stays untouched — still used for disc 1 and the par2-damage re-insert path (same-disc semantics, different concern).

Test plan

  • Normal 2+ disc chain: disc 1 prompts, disc 2 auto-detected after eject + reinsert.
  • Press 'e' after disc 1 → extraction runs against just that disc.
  • Insert a wrong-chain disc as disc 2 → warning + auto-eject + resumes polling.
  • Insert a blank / non-archive disc → warning + auto-eject + resumes polling.
  • Ctrl+C during the wait → clean exit 130, terminal not stuck in cbreak.
  • bd-archive extract … | tee log.txt (non-TTY stdout) → no spinner spam, still works.
  • bd-archive extract … < /dev/null (non-TTY stdin) → warns about 'e', polling still functions.

🤖 Generated with Claude Code

Discs ≥ 2 are detected by polling drive_status. Press 'e' (single
keypress via cbreak stdin) to stop collecting and proceed to the
extraction phase. Disc 1 keeps the classic Enter prompt so the user
can read the header info before the run starts.

Drops the trailing `prompt_yn("Insert another disc?")` and the
`prompt_disc("Insert disc N")` confirmation for every N ≥ 2.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Xitee1 Xitee1 merged commit 0f44e08 into main May 19, 2026
1 check passed
@Xitee1 Xitee1 deleted the feat/extract-auto-detect-disc branch May 19, 2026 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant