Repository navigation
Conversation
dekrom
force-pushed
the
fix/atomic-config-save
branch
from
December 1, 2026 21:35
96445b8 to
33b1972
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of change
Description
System#savewrites to a temp file and then moves it over the target, which is the right shape,but the temp file is created with no directory argument:
so it lands in
java.io.tmpdirwhile the target is under the game directory. When those aredifferent filesystems the atomic move can't work,
Files.movethrowsAtomicMoveNotSupportedException, and the fallback isStreamUtils.copy, a plainFiles.copy(..., REPLACE_EXISTING). That deletes the old file and writes the new one in place,so a kill or a full disk part way through leaves the config missing or cut short, and the
IOExceptiononly ends up in the log./tmpbeing its own tmpfs mount is the systemd default, and on Windows%TEMP%is often on adifferent drive than the instance, so for a lot of people this isn't the rare fallback, it's every
save.
Resolving the destination first and creating the temp file next to it puts the move back on one
filesystem, so it stays atomic. The copy fallback stays for anything exotic. The temp file now
ends in
.tmpinstead of the target's name, so if one is ever left behind in a profile foldernothing that scans for
*.nbtpicks it up.Related issues
None that I found.
How Has This Been Tested?
Checked that
/tmpis a separate tmpfs mount from the game directory on my machine, so every savethere went through the copy. With the change, a full quit writes every config, including the
profile and waypoint files, and leaves no temp files behind. I haven't killed the process mid-save
to produce a broken config.
Checklist: