Skip to content

Conversation

@jnsebgosselin
Copy link
Member

@jnsebgosselin jnsebgosselin commented Sep 23, 2025

This PR adds an option to perform atomic file saves in the SaveFileManager class.

Atomic saving first writes data to a temporary file, then replaces the target file in a single operation. This minimizes the risk of data loss or corruption from partial writes. The new atomic flag allows users to enable or disable this behavior as needed, with backward compatibility preserved.

Includes:

  • New atomic parameter for SaveFileManager
  • Updated save logic to support atomic file operations
  • Tests for both atomic and non-atomic save modes

Atomic writes (or atomic saving) refer to a file-saving strategy where data is first written to a temporary file and, upon successful completion, the temporary file is moved or renamed to replace the original file in a single operation. This ensures that the file is never left in a partially written or corrupted state: the update either happens completely, or not at all. Atomic saving increases data integrity and safety, especially in the event of program crashes or interruptions during the save process.

@jnsebgosselin jnsebgosselin added the enhancement New feature or request label Sep 23, 2025
@jnsebgosselin jnsebgosselin modified the milestones: 0.9.1, 0.9.2 Sep 23, 2025
@jnsebgosselin jnsebgosselin self-assigned this Sep 24, 2025
@jnsebgosselin jnsebgosselin merged commit 75a3cb1 into main Sep 24, 2025
1 check passed
@jnsebgosselin jnsebgosselin deleted the support_atomic_write_savefile_manager branch October 7, 2025 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants