Skip to content

bink_index: an unreadable input directory is an error, not a silent skip - #4767

Closed
Atomic258 wants to merge 1 commit into
ItsNotRexed:mainfrom
Atomic258:bink-index-walk-error
Closed

Atomic258 wants to merge 1 commit into
ItsNotRexed:mainfrom
Atomic258:bink-index-walk-error

Conversation

@Atomic258

Copy link
Copy Markdown
Contributor

Item: BUILD item claimed in #4683 (claim) — the os.walk pass, second of this pair.

tools/bink_index.py had the same silent-skip hole in two places:

  • scan_target walks the target tree with no onerror, so an unreadable subtree's .bk2 files silently missing from the index at exit 0. The OSError now propagates to main()'s existing cannot read + rc 2 handler.
  • The --out overwrite safety check (main) walks the target outside any error handler — an unreadable subtree there could hide the input file the check exists to protect. It now fails closed with the same cannot read + rc 2.

Tests: tests/test_bink_index.py gains three synthetic os.scandir-patch cases (no game data): scan_target raises, main on an unreadable target reports rc 2, and the --out check refuses rather than skipping the subtree (output file verified untouched). All three red on 98fa503f, green here. 22/22 pass; compileall and git diff --check clean.

AI-assisted (Devin). No GPU needed — CPU-only tool.

scan_target walked the target tree with no onerror, dropping unreadable subtrees from the index at exit 0, and the --out overwrite check had the same hole outside any error handler. Both walks now raise; scan_target's reaches main()'s cannot-read rc 2, the check fails closed the same way.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran this at 0e33a9e2f on Windows 11: pytest tests/test_bink_index.py -q -> 22 passed, 14 subtests passed; git diff --check clean.

An unreadable input directory is now an error line (exit 2) rather than a silent skip, and the walk guard covers the nested cases; the added tests pin the unreadable, nested and ordinary paths. No blocking issue.

@Atomic258

Copy link
Copy Markdown
Contributor Author

Closing as a duplicate — @SebSilent's #4372 (opened 01:05 UTC, ~4h before this PR) already adds the raising onerror to bink_index.scan_target's walk. Theirs is earlier; theirs wins.

One small delta in case it's useful as a follow-up rather than lost work: my version also covered the --out overwrite safety walk in main() (~line 319), which sits outside any OSError handler — an unreadable subtree there could hide the input the check exists to protect. #4372 doesn't touch that second walk; if the maintainer wants it, it could ride along as a tiny follow-up.

@Atomic258 Atomic258 closed this Nov 23, 2026
@Atomic258

Copy link
Copy Markdown
Contributor Author

Tested 0e33a9e on Windows Server 2022, CPython 3.13.12: pass

  • python -I tests/test_bink_index.py -> OK
  • Negative control (tools/bink_index.py swapped to upstream/main): FAILED (failures=3)

git diff --check clean; python -m compileall -q exit 0. No game files, no GPU. AI-assisted (Devin).

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.

2 participants