Repository navigation
bink_names: a sub-folder the --out check cannot list is an error, not a silent skip (BUILD-1374) - #4728
bink_names: a sub-folder the --out check cannot list is an error, not a silent skip (BUILD-1374)#4728rafaelpssz wants to merge 1 commit into
Conversation
… 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
left a comment
There was a problem hiding this comment.
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.
|
Tested head
All pass. AI-assisted (Devin). |
|
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). |
|
Tested
|
BUILD-1374, one tool per PR as the item asks (claim).
What
tools/bink_names.pymain()checks that an existing--outfile isn't one of the inputs before overwriting it. That check walks each input folder withos.walkand noonerror, so a sub-folder it can't list is skipped in silence. An--outthat sits inside such a folder passes the check and gets overwritten.Now
onerrorcallsap.error: it names the folder and exits 2 before anything is written, the same way the existing "--outwould 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
TestCli.test_overwrite_check_fails_on_an_unlistable_sub_folderintests/test_bink_names.py. Like save_keys: fail on an unlistable sub-folder instead of silently skipping its saves #4385 and vertex_types: fail on an unlistable sub-folder instead of silently skipping its archives #4417, it makesos.scandirraisePermissionErrorfor one sub-folder, then checks exit code 2, that the folder is named, that there is no traceback, and that the existing report is unchanged.tests/test_bink_names.pypasses 32/32.compileall -q tools testsandgit diff --checkare clean, and no line is over 120 columns.Thanks
By @rafaelpssz, with Claude Code (AI-assisted).