Repository navigation
bvh_index: a sub-folder the report-path check cannot list is an error, not a silent skip (BUILD-1374) - #4729
rafaelpssz wants to merge 1 commit into
Conversation
… a silent skip (BUILD-1374) When --out or --csv names an existing file and the target is a folder, main() walks the 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 flag and the folder and exits 2 before anything is written, like the other "would overwrite" refusals. The scan itself (scan_dir, glob on main) is left to ItsNotRexed#4431, which turns it into an os.walk whose unlistable folders are logged and make the run exit 1 as incomplete. 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 c8f263917 on Windows 11: pytest tests/test_bvh_index.py -q -> 34 passed, 1 skipped, 2 subtests passed; git diff --check clean.
A sub-folder the report-path check cannot list is now an error (exit 2) rather than a silent skip, with the existing report tests unchanged. No blocking issue.
|
Tested What I ran:
Code review:
|
|
Tested head
All pass. AI-assisted (Devin). |
|
Code read + CPU tests, c8f2639: pass ( |
|
Verified on Linux: all 35 tests pass under python -I and test_bink_names is unaffected. Same shape as the #4728 fix in the sibling tool, including the Windows-portable mock test; the closure correctly attributes the error to the flag whose walk failed. 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/bvh_index.pymain()checks, when the target is a folder, that--out/--csvisn't a file inside it before writing. That walk (os.walk(a.target), ~line 499) has noonerror, so a sub-folder it can't list is skipped in silence. A report path inside such a folder passes the check and the file gets overwritten.Now
onerrorcallsap.error: it names the flag and the folder and exits 2 before anything is written.Error, not a logged skip: this walk is a safety check, for the same reason as in
bink_names.The folder scan itself (
scan_dir) is not touched. The open #4431 rewrites it, with unlistable folders reported as logged skips. This PR changes only the overwrite check, which no open PR edits. #3143, #3107, #3098, #4556 and #4431 edit nearby lines ofmain(), so whichever lands second may need a small rebase.Tests
ScanTest.test_overwrite_check_fails_on_an_unlistable_sub_folderintests/test_bvh_index.py, withos.scandirraisingPermissionErrorfor one sub-folder.tests/test_bvh_index.pypasses 35 tests with 1 skipped. The skipped test is POSIX-only and was skipped before this change too.compileallandgit diff --checkare clean.Thanks
By @rafaelpssz, with Claude Code (AI-assisted).