Skip to content

awc_markers: preserve the report when a directory cannot be read - #6774

Merged
shayderrr merged 1 commit into
ItsNotRexed:mainfrom
Solthodox:fix/awc-markers-incomplete-scan
Nov 23, 2026
Merged

shayderrr merged 1 commit into
ItsNotRexed:mainfrom
Solthodox:fix/awc-markers-incomplete-scan

Conversation

@Solthodox

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: four media-tool items on #6603, awc_markers item.

Depends on: #3916, #5723 (textual overlap in traversal / the call to scan; neither implementation is incorporated).

What and why

A recursive os.walk silently skipped an unreadable subdirectory. With readable banks plus a mode-000 child, main returned success and published incomplete bank and event counts. Propagate listing failures and report scan I/O errors before writing the report or printing a summary. This is independent of output-path validation in #5723.

Tested

AI-assisted: yes.

Checklist

  • No game data, keys or decryption, including in logs or reports quoted here. All fixtures were synthetic.
  • Translator-rule contract: not applicable; no translator changes.

Propagate directory traversal errors and preserve the previous report when a bank cannot be read.
@kapitche

Copy link
Copy Markdown
Contributor

Tested 69e3af8 merged with main 1cc6e3c on Linux/Python 3.12.16: pass

Commands (clean merge, git merge --no-edit of the PR head onto upstream/main):

  • ~/src/Leonida/.venv/bin/python -I tests/test_awc_markers.py: Ran 9 tests, OK (includes the new test_unlistable_child_preserves_the_previous_report).
  • Negative control: git checkout upstream/main -- tools/awc_markers.py, same command: FAILED (failures=1), test_unlistable_child_preserves_the_previous_report: AssertionError: 0 != 1 (the unlistable directory was silently skipped and exit code was 0). Restored the file afterwards.

Diff read: os.walk(..., onerror=) re-raises, and main turns the OSError into exit 1 with the path on stderr before --out is opened, so the earlier report is left untouched. One note, not a blocker: the new test injects the failure by patching os.scandir rather than using a real permission-denied directory, so it does not exercise OS-level permissions; the unreadable-bank case (scan on a single file) goes through the same OSError handler but has no test of its own.

@shayderrr shayderrr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Summary

awc_markers.scan() now walks directories with os.walk(src, onerror=scan_failed), where the new callback re-raises the OSError, so an unreadable child bank aborts the scan instead of silently skipping it. main() wraps scan() in try/except OSError, reports cannot read <path>: <strerror> to stderr, returns 1, and never opens the --out report. The new test_unlistable_child_preserves_the_previous_report patches os.scandir to raise PermissionError on one child and asserts the pre-existing markers.json survives byte-for-byte with an empty stdout.

Why merge

A partially scanned directory previously published a plausible-looking but incomplete marker census over the prior report; failing loudly keeps the last good data intact.

Verdict: Approve

@shayderrr

Copy link
Copy Markdown
Collaborator

Summary

awc_markers.scan() now walks directories with os.walk(src, onerror=scan_failed), where the new callback re-raises the OSError, so an unreadable child bank aborts the scan instead of silently skipping it. main() wraps scan() in try/except OSError, reports cannot read <path>: <strerror> to stderr, returns 1, and never opens the --out report. The new test_unlistable_child_preserves_the_previous_report patches os.scandir to raise PermissionError on one child and asserts the pre-existing markers.json survives byte-for-byte with an empty stdout.

Why merge

A partially scanned directory previously published a plausible-looking but incomplete marker census over the prior report; failing loudly keeps the last good data intact.

Verdict: Approve

@shayderrr
shayderrr merged commit e6be35a into ItsNotRexed:main Nov 23, 2026
0 of 2 checks passed
zzEmmazz added a commit to zzEmmazz/Leonida that referenced this pull request Nov 23, 2026
main already has the tool (an earlier head of this branch) and, since ItsNotRexed#6774, an OSError check for an
unlistable folder in the lines this branch changed. Both are kept: input_paths() does the walk with
main's onerror, scan() and the --out check use it, and main() reports an OSError from either.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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.

3 participants