Skip to content

rbf0_tree: guard out/--csv/--xml with the shared report_paths.same_report_path (EGEN-RBF0-TREE-SHARED) - #6176

Open
evilclanker9000 wants to merge 2 commits into
ItsNotRexed:mainfrom
evilclanker9000:deepseek/4-rbf0-tree-shared-path
Open

evilclanker9000 wants to merge 2 commits into
ItsNotRexed:mainfrom
evilclanker9000:deepseek/4-rbf0-tree-shared-path

Conversation

@evilclanker9000

Copy link
Copy Markdown
Contributor

tools/rbf0_tree.py carried its own same_output_path (realpath + normcase + samefile) for the guards that keep the JSON out, the --csv report and the --xml folder from replacing the source. Those rules only fold case on Windows, so on a Linux mount that ignores case (vfat, exFAT, CIFS) RBF0.RBF and rbf0.rbf passed as two names and the report replaced the source stream or the other report.

tools/report_paths.py is the one helper for this: it takes the same two branches and then asks the volume itself with one scratch folder (same_name_on_folding_volume). rbf0_tree now imports same_report_path and the private copy is gone; the four guards (--out vs --csv, --out/--csv vs a source file, --out/--csv vs a stream in a carve folder, --xml vs the source folder) call it. The error messages are unchanged.

EGEN-RBF0-TREE-SHARED.

Test

tests/test_report_paths.py already keeps the list of tools that must use the shared helper. Adding rbf0_tree to it fails on the old file and passes on the new one:

python -I tests/test_report_paths.py

Before the change (private copy in place, rbf0_tree listed in SHARED):

FAIL: test_switched_tools_import_the_helper_and_define_no_copy
  File "tests/test_report_paths.py", line 189
    self.assertIn("from report_paths import same_report_path", source)
AssertionError: 'from report_paths import same_report_path' not found in ...
Ran 21 tests in 7.735s
FAILED (failures=1)

After the change:

Ran 21 tests in 7.776s
OK

The tool's own suite is unchanged and still green: python -I tests/test_rbf0_tree.py -> Ran 36 tests ... OK (skipped=1).

No GPU needed; the case-folding branch of the helper is exercised with patches in test_report_paths.py, so it runs on Windows.

Notes

I picked rbf0_tree.py because the other tools of this kind already have an open pull request in flight (rbf0_index, bink_index/skin_streams, world_census, vertex_types, tex_headers, pe_inspect, instance_lists, shader_profile) and rbf0_tree had no claim. Nothing else in the file changed; rbf0_index, which it imports for the constants, is untouched.

AI-assisted.

…port_path

The private same_output_path copy compared realpath+normcase and samefile only, so a case-only spelling of the report path on a volume that folds case without normpath saying so (a vfat/exFAT/CIFS mount on Linux) passed the guard and the report replaced the source stream. tools/report_paths.py asks the volume itself for that pair.
Without the import the new entry fails, so a re-added private copy is caught by the suite.
@shdann

shdann commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

The XML export can still replace a single input file at 83460eca. The tool accepts a valid RBF0 stream named 00000000.xml. When --xml names its parent directory, the first generated XML path is the input path. The command exits 0 and replaces the original stream with XML. The expected result is a path error before publication, with the source bytes intact. The merge base 561b65a8 behaves the same way.

I used the existing synthetic fixture. Run this from the repository root with py -3.14 -I - on Windows. It creates all files in a new temporary directory.

import runpy, subprocess, sys, tempfile
from pathlib import Path
sample = runpy.run_path("tests/test_rbf0_tree.py")["wide_blob"]()
with tempfile.TemporaryDirectory() as d:
    folder = Path(d)
    src = folder / "00000000.xml"
    src.write_bytes(sample)
    r = subprocess.run([sys.executable, "-I", "tools/rbf0_tree.py", str(src),
                        str(folder / "report.json"), "--xml", d], capture_output=True, text=True)
    print(r.returncode, src.read_bytes() == sample, src.read_bytes()[:16], r.stderr)

The result starts with 0 False. Check the generated XML paths against the input and the other requested reports before writing any output.

The tree and report-path suites ran 57 tests on the head. 55 passed and two skipped. The new helper-registration check fails against the merge base for rbf0_tree as expected.

AI-assisted.

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