Viewer: atomic writes for map bake, caches and settings (SIX-203) #261

Manually merged
github merged 3 commits from gh-pr/261/head into gh-pr/261/base 2026-11-26 20:22:27 +00:00
Owner

@⁠holdmysocks on GitHub · 2026-11-25 12:08 UTC · original
holdmysocks:six-203-viewer-atomic → master · +479 −257 · 57 files · 3 commits · merged 2026-11-25 12:46 UTC

Stacked on #259. Merge that first; this PR then shows only its own commit.

The viewer's own output writes now go through sixng_core::atomic (temp file + rename), like the exports in #259:

  • Map bake: top.bin, entities.bin and lights.bin streams, plus heights, strings, interiors, meta, junction and cache json.
  • Caches: cell caches and reduced-texture caches. These used one fixed temp name per file, which two threads or two viewers could share. They now get unique temp names.
  • Other files: saved GLBs, livery and zone files, settings, the picker settings, map3d and pages json, and audio saves.

Test fixtures are unchanged.

cargo check --workspace --all-targets is clean, and cargo test -p sixng-core -p sixng-gui --release passes.

**@⁠holdmysocks** on GitHub · 2026-11-25 12:08 UTC · [original](https://github.com/holdmysocks/SixNG/pull/261) `holdmysocks:six-203-viewer-atomic` → `master` · +479 −257 · 57 files · 3 commits · merged 2026-11-25 12:46 UTC Stacked on #259. Merge that first; this PR then shows only its own commit. The viewer's own output writes now go through `sixng_core::atomic` (temp file + rename), like the exports in #259: - **Map bake:** `top.bin`, `entities.bin` and `lights.bin` streams, plus heights, strings, interiors, meta, junction and cache json. - **Caches:** cell caches and reduced-texture caches. These used one fixed temp name per file, which two threads or two viewers could share. They now get unique temp names. - **Other files:** saved GLBs, livery and zone files, settings, the picker settings, map3d and pages json, and audio saves. Test fixtures are unchanged. `cargo check --workspace --all-targets` is clean, and `cargo test -p sixng-core -p sixng-gui --release` passes.
Every export write now goes through sixng_core::atomic: the data goes to a
hidden temp file in the target's folder and is renamed over the target, so a
killed run keeps the old file and two writers leave one whole copy instead of
a short file followed by an older file's tail (or a zero-filled file).

- atomic::write replaces fs::write; atomic::AtomicFile replaces the
  BufWriter<File> streams (jsonl, batch bins, gz indexes, movies, PNGs).
  Hand-rolled temp + rename code (some with per-thread temp names that two
  processes could share) now uses the helper.
- Model and texture dictionary folders are locked while they are written
  (a lock file held on an open handle, freed if the process dies); a second
  run waits up to two minutes, then reports the folder as busy. The lock
  holder clears temp files that killed runs left behind.
- The skip-if-present check treats a model.json or dictionary.json that
  does not parse as missing, so a re-run without --force repairs it.
- Tests: overlapping writers, a killed write, bad JSON, and the lock.
The viewer's own output writes now use sixng_core::atomic like the exports:
map bake files (top.bin, entities.bin, lights.bin, heights, strings,
meta and junction json), cell and texture caches, saved GLBs, livery
files and settings. The cell and reduced-texture caches used one fixed
temp name per file, which two threads or two viewers could share; they
now get unique temp names.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:22:25 +00:00
github manually merged commit d3096e609b into gh-pr/261/base 2026-11-26 20:22:27 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.