mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-22 07:32:32 +01:00
Strengthen savedata persistence against corruption and race conditions: - SHA-256 checksum: hash the decompressed blob on every save, store in new savedata_hash column, verify on load to detect silent corruption. Pre-existing characters with no hash are silently upgraded on next save. - Atomic transactions: wrap character data + house data + hash + backup into a single DB transaction via SaveCharacterDataAtomic, so a crash mid-save never leaves partial state. - Per-character save mutex: CharacterLocks (sync.Map of charID → Mutex) serializes concurrent saves for the same character, preventing races that could defeat corruption detection. Different characters remain fully independent. Migration 0008 adds the savedata_hash column to the characters table.
5 lines
252 B
SQL
5 lines
252 B
SQL
-- Add SHA-256 checksum column for savedata integrity verification.
|
|
-- Stored as 32 raw bytes (not hex). NULL means no hash computed yet
|
|
-- (backwards-compatible with existing data).
|
|
ALTER TABLE characters ADD COLUMN IF NOT EXISTS savedata_hash BYTEA;
|