From 50e97c19384b394a899337f967d54405d6128720 Mon Sep 17 00:00:00 2001 From: erdemcisse Date: Tue, 1 Dec 2026 21:50:18 +0100 Subject: [PATCH] navmesh_decode: ask report_paths for the report-path guard (the last legacy copy) The tool carried its own `same_report_path`: normcase(realpath) plus samefile. That copy is older than the shared one and misses both cases the shared one grew for -- the volume probe for a case-folding Linux mount (vfat, exFAT, CIFS) and the case-sensitive-directory check on Windows -- so "--out R.json" and a carve manifest "r.json" on such a volume went unnoticed and the run overwrote the manifest. tests/test_report_paths.py named it the one remaining legacy copy and asked for the import instead. LEGACY_COPIES is now empty: every tool takes the guard from tools/report_paths.py, and the identity test covers the re-exported name the siblings import. Verified: python -I tests/test_report_paths.py (fails on main: navmesh_decode's same_report_path is not the shared one, and the SHARED scan finds a copy), tests/test_navmesh_decode.py, test_navmesh_nodes.py, test_navmesh_links.py, test_navmesh_cell_fit.py, scripts/check_no_game_data.py on both files, and the docs/hygiene suite (57 tests). No game files, no GPU. --- tests/test_report_paths.py | 11 +++++------ tools/navmesh_decode.py | 38 +------------------------------------- 2 files changed, 6 insertions(+), 43 deletions(-) diff --git a/tests/test_report_paths.py b/tests/test_report_paths.py index 5a22fe2cc5..0d59ca3d5f 100644 --- a/tests/test_report_paths.py +++ b/tests/test_report_paths.py @@ -22,11 +22,10 @@ # Tools that use report_paths and must not define their own copy again. SHARED = ("anim_index", "awc_manifest", "bink_index", "gamedata_index", "gamedata_xml", "gen_d3d12_stubs", - "glb_inspect", "meshlet_page", "navmesh_index", "rpf_probe", "tile_probe", "world_index", - "world_lights_paths", "world_names") -# The one tool that still carries its own copy (an open pull request edits its call site). Do not add to this list: -# import report_paths instead. -LEGACY_COPIES = {"navmesh_decode"} + "glb_inspect", "meshlet_page", "navmesh_decode", "navmesh_index", "rpf_probe", "tile_probe", + "world_index", "world_lights_paths", "world_names") +# No tool carries its own copy any more: import report_paths instead. Do not add to this list. +LEGACY_COPIES = set() def touch(path): @@ -259,7 +258,7 @@ def test_no_new_copies_of_same_report_path(self): def test_tools_still_expose_same_report_path(self): # gamedata_xml.py and others call it by this name (and tests or sibling tools may import it). - for tool in ("gamedata_index", "gamedata_xml", "navmesh_index", "world_index"): + for tool in ("gamedata_index", "gamedata_xml", "navmesh_decode", "navmesh_index", "world_index"): with self.subTest(tool=tool): module = __import__(tool) self.assertIs(module.same_report_path, report_paths.same_report_path) diff --git a/tools/navmesh_decode.py b/tools/navmesh_decode.py index 6490dec125..dcb872098f 100644 --- a/tools/navmesh_decode.py +++ b/tools/navmesh_decode.py @@ -49,7 +49,6 @@ import struct import sys import time -import unicodedata import zlib from collections import Counter from collections.abc import Iterator @@ -57,6 +56,7 @@ ROOT = os.path.dirname(os.path.abspath(__file__)) if ROOT not in sys.path: sys.path.insert(0, ROOT) +from report_paths import same_report_path # noqa: E402 from zero_span import gap_split # noqa: E402 BASE = 0x50000000 @@ -1048,42 +1048,6 @@ def _offset(text): return value -_PC_CASE_SENSITIVE = 11 # on macOS; os.pathconf_names doesn't list it - - -def _case_insensitive_volume(path): - """True when the volume that will hold `path` ignores letter case, as macOS's default APFS volume does. - os.path.normcase folds case only on Windows, so on macOS `R.json` and `r.json` would pass as two reports.""" - if sys.platform != "darwin": - return False - while not os.path.exists(path): - parent = os.path.dirname(path) - if parent == path: - break - path = parent - try: - return os.pathconf(path, _PC_CASE_SENSITIVE) == 0 - except (OSError, ValueError): - return True # the macOS default; folding can only refuse a pair, never overwrite one - - -def _path_key(path): - path = os.path.normcase(os.path.realpath(path)) - if _case_insensitive_volume(path): - # APFS and HFS+ also treat composed and decomposed accents as one name. - path = unicodedata.normalize("NFD", path.casefold()) - return path - - -def same_report_path(first, second): - if _path_key(first) == _path_key(second): - return True - try: - return os.path.samefile(first, second) - except OSError: - return False - - def main(argv=None): ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) ap.add_argument("input", help="RPF9 archive (navmeshes.rpf) or directory of carved streams")