Skip to content

Write mod-owned payload files through the staging helper - #122

Open
sambvfx wants to merge 1 commit into
NVIDIAGameWorks:mainfrom
sambvfx:stage-mod-owned-payload-writes
Open

sambvfx wants to merge 1 commit into
NVIDIAGameWorks:mainfrom
sambvfx:stage-mod-owned-payload-writes

Conversation

@sambvfx

@sambvfx sambvfx commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

The runtime textures and the restore of a missing rtx.conf did not get the staged write that #103 gave the author-owned payload. Both now use the same helper.

Changes

  • Textures. extractTextures copied to a staging file and moved it with no retry, and left the staging file behind when either step failed. It now calls writeThroughStaging: copy to <name>.staging, flush, move into place with the usual retries, and remove the staging file if anything fails.
  • rtx.conf restore. restoreMissingRtxConf copied straight onto the live path, so an interrupted copy left a truncated rtx.conf. Because the file then existed, no later launch restored it until the next version change. It now calls writeThroughStaging too.
  • rtx.conf swap. The swap at the end of a full extraction now uses moveReplacing. Its comment said the move was ReplaceFileW underneath. A REPLACE_EXISTING move without ATOMIC_MOVE deletes the target and then renames, which left a moment with no live conf.
  • Flush cost. The JAR ships one texture of about 0.7 MB, and writing a file of that size took 3.2 ms with the flush against 0.6 ms without on a SATA SSD.

Testing

  • DirectoryRuntimePayloadTest gains three tests, each of which failed before the change:
    • a texture copy that fails partway left its staging file behind;
    • a texture move blocked by an open handle failed at once instead of succeeding when the handle closed;
    • an rtx.conf restore that fails partway left a truncated conf.
  • gradlew build test passes for each 1.21.1 loader with 0 failures: Fabric 925 JVM tests, Forge 905, NeoForge 899.
  • The rtx.conf swap has no test of its own. The difference shows only if the process dies between the delete and the rename.
  • Not run in a game.

🤖 Generated with Claude Code

The runtime textures and the restore of a missing `rtx.conf` each had
their own way of writing a file. `extractTextures` copied to a staging
file and moved it with no retry, and left the staging file behind when
either step failed. `restoreMissingRtxConf` copied straight onto the
live path, so an interrupted copy left a truncated `rtx.conf`. Because
the file then existed, no later launch restored it until the next
version change.

Both now call `writeThroughStaging`, the helper the author-owned
payload uses: copy to `<name>.staging`, flush, move into place with the
usual retries, and remove the staging file if anything fails.

The `rtx.conf` swap at the end of a full extraction now uses
`moveReplacing`. Its comment said the move was `ReplaceFileW`
underneath. A `REPLACE_EXISTING` move without `ATOMIC_MOVE` deletes the
target and then renames, which left a moment with no live conf.

The flush is cheap here. The JAR ships one texture of about 0.7 MB, and
writing a file of that size took 3.2 ms with the flush against 0.6 ms
without on a SATA SSD.

## Testing

- `DirectoryRuntimePayloadTest` gains three tests, each of which failed
  before the change:
  - a texture copy that fails partway left its staging file behind;
  - a texture move blocked by an open handle failed at once instead of
    succeeding when the handle closed;
  - an `rtx.conf` restore that fails partway left a truncated conf.
- `gradlew build test` passes for each 1.21.1 loader with 0 failures:
  Fabric 925 JVM tests, Forge 905, NeoForge 899.
- The `rtx.conf` swap has no test of its own. The difference shows only
  if the process dies between the delete and the rename.
- Not run in a game.

Signed-off-by: Sam Bourne <sbourne@nvidia.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant