Prevent server.properties overwrite in Settings and DedicatedServerSettings #4

Merged
NotAlexNoyle merged 2 commits from codex/patch-server.jar-to-preserve-server.properties-7sk4pj into ver/1.19.4 2026-01-24 11:25:00 -05:00
NotAlexNoyle commented 2026-01-24 11:24:00 -05:00 (Migrated from github.com)

Motivation

  • The server was still overwriting an existing server.properties file despite an earlier patch, so writes must be guarded at the central store point as well as the dedicated-server save path.
  • Ensure configuration persistence never clobbers an existing file created or managed externally.

Description

  • Add import java.nio.file.Files and an early-exit if (Files.exists(path)) return; guard to Settings.store(Path) so the base store method will skip writes when the target exists.
  • Add the same Files.exists(this.path) check to DedicatedServerSettings.save() to prevent the dedicated-server save flow from overwriting an existing file.
  • Update the patch file patches/server/0313-Prevent-server-properties-overwrite.patch to include both changes so both codepaths are covered.

Testing

  • No automated tests were run for this change.

Codex Task

### Motivation - The server was still overwriting an existing `server.properties` file despite an earlier patch, so writes must be guarded at the central store point as well as the dedicated-server save path. - Ensure configuration persistence never clobbers an existing file created or managed externally. ### Description - Add `import java.nio.file.Files` and an early-exit `if (Files.exists(path)) return;` guard to `Settings.store(Path)` so the base store method will skip writes when the target exists. - Add the same `Files.exists(this.path)` check to `DedicatedServerSettings.save()` to prevent the dedicated-server save flow from overwriting an existing file. - Update the patch file `patches/server/0313-Prevent-server-properties-overwrite.patch` to include both changes so both codepaths are covered. ### Testing - No automated tests were run for this change. ------ [Codex Task](https://chatgpt.com/codex/tasks/task_e_696fa6096ac8832fa894d6a343f480ae)
Sign in to join this conversation.