Commit Graph

22 Commits

Author SHA1 Message Date
e0e50e30c7 tests/test_manifest: remove unused import shutil 2026-11-30 13:38:51 +03:00
cc5d5e3123 manifest: restore write mode before unlink on replace failure and publish mode (MANIFEST-STAGE-CLEANUP)
Apply published_mode(out) to staged manifest file before atomic replacement,
and restore write permission (0o600) before TemporaryDirectory cleanup in
exception block when replace fails, preventing Windows PermissionError [WinError 5]
and stranded temporary files.

agent: yes
AI-assisted: yes
2026-11-29 18:24:12 +03:00
9541c00907 manifest: hash through one reused buffer, halving peak chunk memory per worker (OLD-4922)
_hash_file() read each 8 MiB chunk with f.read(), which allocates the next
bytes object while the last one is still referenced: two chunks per worker
at the peak. With --jobs N that is 16 MiB times N for hashing alone.

It now fills one memoryview-backed bytearray with readinto(), as
manifest_verifier.sha256_file() already does. Digests, sizes and the
change-during-read checks are unchanged.

Measured on a 320 MiB file: tracemalloc peak 16.0 -> 8.0 MiB.

Tests: a multi-chunk file must hash right with a peak under 1.5 chunks, a
short readinto() must not skip or repeat bytes, and the edit-during-read
case hooks readinto, the call the tool now makes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-23 21:24:10 -05:00
3e1e6ea119 manifest: take the --out/input guard from report_paths (EGEN-MANIFEST-SHARED-PATH) (#6677)
Squash-merged after diff review of PR #6677
2026-11-23 10:59:34 -06:00
b23779d6a9 tests: pass errors=replace to subprocess pipes capturing python -I tools 2026-11-23 00:42:37 +02:00
282444cb06 Merge pull request #3042 from tupacfan04 2026-11-22 15:14:19 -05:00
c9db3cfa03 manifest: verify refuses an empty files table for a folder with files
verify printed OK and exited 0 for an empty "files" table even when the folder held files, so make_game.py's package check verified nothing. Reject that case with one ERROR line and exit 2; keep the empty-folder round trip that create writes and the tests rely on.
2026-11-22 13:11:20 -06:00
f4a8990953 Merge pull request #2518 from Narek Shaghoyan 2026-11-22 13:15:52 -05:00
9a16d74719 manifest: preserve literal backslashes in POSIX filenames
In tools/manifest.py walk(), unconditional .replace("\\", "/") collapsed literal backslashes in POSIX filenames into "/", causing distinct files such as sub/a.dat and sub\a.dat to collide in create() and verify() and diverging from manifest_verifier.py (#2235). Normalize only os.sep/os.altsep when distinct from "/", and add a POSIX regression test.
2026-11-22 17:19:48 +00:00
366fcfd555 Merge pull request #2044 from Vonsek 2026-11-22 11:41:10 -05:00
cc497a86c6 fix(manifest): pin verification to the expected file size
A file can resize after the directory scan. Check the expected size again on the handle used for hashing so verification cannot combine a size and digest from different versions of the file.
2026-11-22 16:41:54 +01:00
1472d9e471 Merge pull request #2004 from richardsenra 2026-11-22 10:40:21 -05:00
7892238c02 manifest: compare SHA-256 digests without case sensitivity (BUILD-549)
Normalize the expected hex digest before serial or parallel verification. Add synthetic API and CLI regressions for case variants, altered content, missing/size errors and malformed digests. AI-assisted with Codex and an independent Claude review.
2026-11-22 12:25:45 -03:00
f341856425 BUILD-536: reject duplicate JSON keys in manifest.py load_manifest() 2026-11-22 16:03:02 +01:00
e620def682 Keep manifest size and hash on a stable file read 2026-11-22 17:39:16 +04:00
6e90a2848b manifest, turing_atlas: refuse report paths that replace inputs or are folders
manifest create --out <game>/a.txt hashed the file and then replaced it
with the manifest (exit 0), so the copy no longer matched the manifest it
had just recorded; turing_atlas --out <existing dir> built the atlas and
then died with a PermissionError. Refuse an existing non-manifest target
inside the hashed folder (and hard links to files that will be hashed)
before hashing, and reject a folder for turing_atlas' --out with one line.
2026-11-22 20:31:59 +08:00
a9cc575f8e manifest.py: exclude the manifest from its own inventory 2026-11-22 00:59:52 +01:00
514e11d848 Isolate concurrent manifest writes before atomic replacement 2026-11-21 20:26:04 -03:00
690e6ee702 manifest.py: report a damaged manifest instead of a traceback; create it atomically
verify read the manifest with json.load(...)["files"] and indexed each entry's "size" and "sha256" directly,
and main caught only OSError. A truncated or malformed manifest therefore ended in a JSONDecodeError, KeyError
or TypeError traceback. load_manifest now checks the JSON, the "files" table and every entry, and raises
ManifestError, which main reports as an ERROR line with exit 2 like a missing file.

create wrote the final manifest in place, so an interrupted run left exactly such a truncated file. It now
writes <out>.partial and swaps it in with os.replace, removing the partial file on any failure; the previous
manifest stays as it was.

The shipped game/xbox-1.0.2.1.json still loads (108 entries).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 00:58:13 +03:00
6139be94f5 manifest.py: fail when the input directory cannot be scanned 2026-11-21 21:47:05 +01:00
4d402c717c test(tools): test manifest directory hashing, creation, verification, and corruption detection 2026-11-21 19:03:20 +01:00
51b79339fb Manifest: hash files with --jobs (parallel create/verify)
Default is half the CPU count; --jobs 1 keeps serial hashing. create rebuilds entries in walk order so the JSON does not depend on completion order, and verify prints problems in manifest order so its output and exit code are identical for every job count. Progress now reports completed file counts from the main thread instead of per-file worker lines.
2026-11-21 17:00:39 +00:00