mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-16 11:49:59 -04:00
The review of the torn-file fix (43ac5ae3) found that pb_index also stops at a malformed record in the middle of the file, so pb_init cuts the file back to it and drops the whole records after it, while its log line and the comment above the cut spoke only of a record half written. It also found that tests/pb_torn_check.py covered only the index walk, not the keep-and-cut that is the fix. The decision after the walk moves from pb_init into pb_keep(path, good, len), which returns the length to go on with (len when the records fill the file, good after cutting it back) or 0 when the file cannot be cut and starts empty; its log line now reads "<path> ends inside a record or holds a malformed one at byte <good>; <n> bytes from there dropped", and the comment and the start-empty reason say the same. Behaviour is unchanged. pb_torn_check.py now also cuts pb_keep out of vk_pipeline.c and runs it on real files, with plat_file_truncate a stand-in that cuts with the C library: a torn file is cut to its whole records and logged, a second walk reaches the end of what is left, a record appended after the cut is read back with the others; a malformed record in the middle is cut off with what follows; a whole file is left as it is, unlogged; and a file that cannot be cut gives 0 and stays as it was. The check passes, vk_pipeline.c compiles, and its -Wall -Wextra warnings are the four it had, none in pb_keep or pb_init. docs/building.md names pb_keep and what the check now covers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>