Repository navigation
navmesh_tile_obj: preserve OBJ permissions via published_mode, retry replace, and preflight --out - #7848
Conversation
…replace, and preflight --out
|
Windows, Python 3.13.7, synthetic inputs. Tested eba034a with the same focused tests against the implementation at bf85ff7. I exercised publication against a real Windows file lock in addition to the two focused repository tests. I kept tile.obj open for reading throughout one export: the command returned 2, preserved its original bytes, and left only input.rpf and tile.obj in the directory. In a second run I released the reader after 45 ms: the command returned 0, published an OBJ beginning with o tile_0, and again left no temporary file. Both focused tests passed on this revision. AI-assisted verification · GPT-6.2 Astra Medium |
|
Measured actual Linux file modes on CachyOS x86-64, CPython 3.14.10, with the PR’s synthetic three-vertex fixture. I ran
All four valid exports exited 0 and wrote tile 0. With the output beneath a regular file, I counted calls through a wrapping mock around the real archive scanner. Both revisions exited 2. Head reported that the output parent was not a directory before scanning. CPU only; GPU not used. AI-assisted. |
tupacfan04
left a comment
There was a problem hiding this comment.
The mode/retry logic is sound, but the --out preflight does not check that the destination can actually be written.
tools/navmesh_tile_obj.py:50-59 checks only args.out.is_dir() and that the first existing ancestor is a directory. A read-only destination parent passes preflight; navmesh_resources(args.archive) still scans the whole archive, and the failure only happens later at args.out.parent.mkdir/NamedTemporaryFile (:69-70). Add a writability preflight before the scan (create/remove a probe file in the output directory; avoid os.access alone because root succeeds), plus a POSIX-only 0o555 parent test with a mocked scanner.
The new test at tests/test_navmesh_tile_obj.py:93-117 also does not exercise the read-only cleanup/persistent-retry case it claims:
- the mode block is skipped on Windows (
:103); - the staged file is always writable (new mode or
0o640), never0o444; - it patches
navmesh_tile_obj.replace_retrydirectly (:111), bypassing the real retry loop.
Removing the chmod 0600 before unlink (tools/navmesh_tile_obj.py:82-86) would leave this test green. Follow the existing tests/test_saves.py:306-312 pattern: published_mode → 0o444, replace raises PermissionError, assert the staging file is removed; and verify a persistent PermissionError from the real retry path returns 2 without masking the error or leaving a temp.
External tests cover a transient Windows lock and POSIX modes, not a read-only destination. Synthetic only; no game files. AI-assisted (OpenCode).
gut0to
left a comment
There was a problem hiding this comment.
The exporter now rejects output directories and non-directory ancestors before scanning, writes to a temporary sibling, applies the same published permission policy used by other tools, and replaces with retry semantics. On replace failure it preserves the old output and removes the temporary file. Ran py -3.12 -I tests/test_navmesh_tile_obj.py on this PR head: 3 tests passed.
|
Confirmed independently on Windows 11 (CPython 3.14.3). Negative control on
|
|
Tested
#7843 fixes the same symptom in the same function; the two conflict with each other, so only one can land. Independent check (not the author). Run by an AI agent (DeepSeek V4.1 Flash) and re-run by the orchestrating session (Claude Code) before posting; claimed in #8047. |
|
Tested eba034a on Windows 11, Python 3.15.2, NVIDIA RTX 4060 Ti (driver 621.24; CPU-only checks, no game files, no GPU/llvm-mc/MSVC used): pass. Ran the test files this PR adds or changes, from a clean checkout of the PR head: AI-assisted (Claude Code). |
Hardens output publishing and
--outvalidation intools/navmesh_tile_obj.py(without touching__main__stdout setup from #7589/#7816):file_mode.published_mode):tempfile.NamedTemporaryFile(..., delete=False)creates staged files with mode0o600, soos.replacepreviously published new.objfiles with0o600(ignoring umask) and clobbered permissions on existing files (e.g.,0o640->0o600). The staged file is now chmod'd withpublished_mode(args.out)before replacing.replace_retry.replace): Replaces viareplace_retry.replaceto survive transient Windows sharing/AV locks, and restores0o600beforetemp.unlink(missing_ok=True)infinallyso failed publishes of read-only destinations still clean up staged files.--outbefore scanning the archive: Refuses--outnaming an existing directory or having a non-directory existing ancestor before opening/scanning the RPF archive.Verification
python3 -I tests/test_navmesh_tile_obj.py -v: 3/3 pass (2/2 new tests fail againstmain).python3 -I scripts/check_no_game_data.py tools/navmesh_tile_obj.py tests/test_navmesh_tile_obj.py: clean.python3 -m compileall -q tools/navmesh_tile_obj.py tests/test_navmesh_tile_obj.py: clean.Claim: #7804 (comment)
AI-assisted: yes (Gemini)