Fix data override prevention on update

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

@ -279,6 +279,7 @@ func handleSaveData(w http.ResponseWriter, r *http.Request) {
} }
} }
if active || r.URL.Path == "/savedata/get" {
switch r.URL.Path { switch r.URL.Path {
case "/savedata/get": case "/savedata/get":
save, err = savedata.Get(uuid, datatype, slot) save, err = savedata.Get(uuid, datatype, slot)
@ -287,12 +288,6 @@ func handleSaveData(w http.ResponseWriter, r *http.Request) {
case "/savedata/delete": case "/savedata/delete":
err = savedata.Delete(uuid, datatype, slot) err = savedata.Delete(uuid, datatype, slot)
case "/savedata/clear": case "/savedata/clear":
if !active {
// TODO: make this not suck
save = savedata.ClearResponse{Error: "session out of date"}
break
}
s, ok := save.(defs.SessionSaveData) s, ok := save.(defs.SessionSaveData)
if !ok { if !ok {
err = fmt.Errorf("save data is not type SessionSaveData") err = fmt.Errorf("save data is not type SessionSaveData")
@ -302,6 +297,11 @@ func handleSaveData(w http.ResponseWriter, r *http.Request) {
// doesn't return a save, but it works // doesn't return a save, but it works
save, err = savedata.Clear(uuid, slot, daily.Seed(), s) save, err = savedata.Clear(uuid, slot, daily.Seed(), s)
} }
} else {
// TODO: make this not suck
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