bug(achievements): XP granted before persistence confirmed — reward lost on crash #56
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Bug
In
achievement_plugin.rs, the flow is:reward_granted = trueIf step 3 fails (disk full, permission error, etc.), the player loses the XP on the next launch because the profile on disk was never updated, but the in-memory flag was already set.
Affected file
solitaire_engine/src/achievement_plugin.rsFix
Invert the order: only set
reward_granted = trueand update the in-memory XP after the save operation returnsOk. Use the result of the save to decide whether to grant the reward, or implement a two-phase commit (write intent → apply → confirm).