add option to flag corruption attempted saves as deleted

This commit is contained in:
wish
2022-12-23 23:18:00 +11:00
parent 7676f2e7d5
commit 9234d82110
3 changed files with 17 additions and 12 deletions

View File

@@ -9,6 +9,7 @@
"PatchServerManifest": "",
"PatchServerFile": "",
"ScreenshotAPIURL": "",
"DeleteOnSaveCorruption": false,
"DevMode": true,
"DevModeOptions": {
"AutoCreateAccount": true,

View File

@@ -22,6 +22,7 @@ type Config struct {
PatchServerManifest string // Manifest patch server override
PatchServerFile string // File patch server override
ScreenshotAPIURL string // Destination for screenshots uploaded to BBS
DeleteOnSaveCorruption bool // Attempts to save corrupted data will flag the save for deletion
DevMode bool
DevModeOptions DevModeOptions

View File

@@ -49,8 +49,11 @@ func handleMsgMhfSavedata(s *Session, p mhfpacket.MHFPacket) {
characterSaveData.Save(s)
s.logger.Info("Wrote recompressed savedata back to DB.")
} else {
s.logger.Warn("Save cancelled due to corruption.")
s.rawConn.Close()
s.logger.Warn("Save cancelled due to corruption.")
if s.server.erupeConfig.DeleteOnSaveCorruption {
s.server.db.Exec("UPDATE characters SET deleted=true WHERE id=$1", s.charID)
}
return
}
_, err = s.server.db.Exec("UPDATE characters SET name=$1 WHERE id=$2", characterSaveData.Name, s.charID)