Skip to content

bink_names: a sub-folder the --out check cannot list is an error, not a silent skip (BUILD-1374) - #4728

Open
rafaelpssz wants to merge 1 commit into
ItsNotRexed:mainfrom
rafaelpssz:fix/walk-bink_names
Open

rafaelpssz wants to merge 1 commit into
ItsNotRexed:mainfrom
rafaelpssz:fix/walk-bink_names

Conversation

@rafaelpssz

@rafaelpssz rafaelpssz commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

BUILD-1374, one tool per PR as the item asks (claim).

What

tools/bink_names.py main() checks that an existing --out file isn't one of the inputs before overwriting it. That check walks each input folder with os.walk and no onerror, so a sub-folder it can't list is skipped in silence. An --out that sits inside such a folder passes the check and gets overwritten.

Now onerror calls ap.error: it names the folder and exits 2 before anything is written, the same way the existing "--out would overwrite …" refusals do.

Error, not a logged skip: this walk is a safety check. Skipping would mean "not checked", and the consequence is overwriting a file.

The other walk in the file (mount_documents, ~line 104) is already handled by the open #4176, so this PR leaves it alone.

Tests

Thanks

By @rafaelpssz, with Claude Code (AI-assisted).

… a silent skip (BUILD-1374)

When --out names an existing file, main() walks every source and mount
folder to make sure the report would not overwrite an input. That
os.walk had no onerror, so a sub-folder it could not list was skipped
and the check passed without having looked inside it: a report file in
that folder could be overwritten.

This is a safety check, so a folder it cannot list is an error: the
walk's onerror calls ap.error, which names the folder and exits 2
before anything is written, like the other "--out would overwrite ..."
refusals. The discovery walk in mount_documents() is left to ItsNotRexed#4176,
which already makes it fail on an unlistable folder.

The test forces os.scandir to raise PermissionError for one sub-folder
(chmod cannot lock a folder on Windows) and checks the exit code, the
folder in the message and that the existing report is untouched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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 f78f7d6a2 on Windows 11: pytest tests/test_bink_names.py -q -> 32 passed, 38 subtests passed; git diff --check clean.

A sub-folder the --out path check cannot list is now an error line (exit 2) instead of a silent skip, so the alias protection cannot be bypassed by an unreadable folder. No blocking issue.

@Atomic258

Copy link
Copy Markdown

Tested head f78f7d6a2a9364cb128c03ac539fe540d5c70df1 on Windows 11, Python 3.15.2 (same SHA as the earlier run above).

  • python -I tests/test_bink_names.py: 32 tests, OK (pytest is not installed on this Python; the file runs fine under unittest)
  • python -m compileall -q tools tests and git diff --check origin/main...HEAD: clean
  • Red control: git checkout origin/main -- tools/bink_names.py, re-ran — the new test_overwrite_check_fails_on_an_unlistable_sub_folder fails with "SystemExit not raised" (1 failure of 32), matching the PR description. Restored the PR file; re-run green, worktree clean.

All pass.

AI-assisted (Devin).

@memorypressure

Copy link
Copy Markdown

Verified on Linux: full suite 32 tests pass under python -I and test_bvh_index (shared same_output_path helper) is unaffected. The os.walk onerror handler is the right mechanism — listing OSErrors route through it and ap.error keeps the one-line exit-2 style — and the mock-scandir test covers the Windows chmod-can't-lock case portably. Report writes stay newline-pinned. Sister of #4729 in the other tool. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

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.

4 participants