Fix data override prevention on update

pull/4/head
Flashfyre 7 months ago
parent 786e947e09
commit 52756fdba3

@ -279,29 +279,29 @@ func handleSaveData(w http.ResponseWriter, r *http.Request) {
} }
} }
switch r.URL.Path { if active || r.URL.Path == "/savedata/get" {
case "/savedata/get": switch r.URL.Path {
save, err = savedata.Get(uuid, datatype, slot) case "/savedata/get":
case "/savedata/update": save, err = savedata.Get(uuid, datatype, slot)
err = savedata.Update(uuid, slot, save) case "/savedata/update":
case "/savedata/delete": err = savedata.Update(uuid, slot, save)
err = savedata.Delete(uuid, datatype, slot) case "/savedata/delete":
case "/savedata/clear": err = savedata.Delete(uuid, datatype, slot)
if !active { case "/savedata/clear":
// TODO: make this not suck s, ok := save.(defs.SessionSaveData)
save = savedata.ClearResponse{Error: "session out of date"} if !ok {
break err = fmt.Errorf("save data is not type SessionSaveData")
} break
}
s, ok := save.(defs.SessionSaveData) // doesn't return a save, but it works
if !ok { save, err = savedata.Clear(uuid, slot, daily.Seed(), s)
err = fmt.Errorf("save data is not type SessionSaveData")
break
} }
} else {
// doesn't return a save, but it works // TODO: make this not suck
save, err = savedata.Clear(uuid, slot, daily.Seed(), s) save = savedata.ClearResponse{Error: "session out of date"}
} }
if err != nil { if err != nil {
httpError(w, r, err, http.StatusInternalServerError) httpError(w, r, err, http.StatusInternalServerError)
return return

Loading…
Cancel
Save