Skip to content

Preserve existing profiles when a save is interrupted - #129

Merged
hbashton merged 1 commit into
hbashton:mainfrom
meiameiameia:fix/atomic-profile-save
Oct 9, 2026
Merged

hbashton merged 1 commit into
hbashton:mainfrom
meiameiameia:fix/atomic-profile-save

Conversation

@meiameiameia

Copy link
Copy Markdown
Contributor

SaveProfileNew currently opens the destination with overwrite enabled. If writing fails after the file is opened, a valid profile can be replaced with incomplete XML.

Write the existing serialized XML to a unique temporary file beside the destination, flush it, then replace the existing profile or move the completed file into place for a new profile. Remove temporary files after failures. The profile schema, serializer and UTF-8 encoding stay the same.

Regression tests cover creation, replacement, interrupted writes with and without an existing destination, locked and read-only destinations, temporary-file cleanup, and the real BackingStore.SaveProfileNew path.

Validation on Windows, .NET SDK 8.0.425, Release x64:

  • All 6 cases in ProfilePersistenceTests passed as part of the combined validation run.
  • 136 related tests passed with both proposed fixes present; this includes existing profile serialization, migration, load preparation and output ownership tests.
  • The patch applies independently to upstream commit 36502408cbba17fd20d84e6b258f2258714a39c6.

This change preserves the existing save exception/return contract. Editor error reporting and rename behavior need a separate fix. Tests use disposable local files; process termination, power loss and network filesystems were not tested.

Focused check:

dotnet test DS4WindowsTests/DS4WindowsTests.csproj -c Release -p:Platform=x64 --filter FullyQualifiedName~ProfilePersistenceTests

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.

2 participants