Fix filesystem error handling
parent
7319f13b44
commit
61d5dd6852
|
@ -136,7 +136,7 @@ func (s *Server) HandleSavedataUpdate(w http.ResponseWriter, r *http.Request) {
|
||||||
compressed := zstdWriter.EncodeAll(gobBuffer.Bytes(), nil)
|
compressed := zstdWriter.EncodeAll(gobBuffer.Bytes(), nil)
|
||||||
|
|
||||||
err = os.MkdirAll("userdata/"+hexUuid, 0755)
|
err = os.MkdirAll("userdata/"+hexUuid, 0755)
|
||||||
if !os.IsExist(err) {
|
if err != nil && !os.IsExist(err) {
|
||||||
http.Error(w, fmt.Sprintf("failed to create userdata folder: %s", err), http.StatusInternalServerError)
|
http.Error(w, fmt.Sprintf("failed to create userdata folder: %s", err), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ func (s *Server) HandleSavedataUpdate(w http.ResponseWriter, r *http.Request) {
|
||||||
compressed := zstdWriter.EncodeAll(gobBuffer.Bytes(), nil)
|
compressed := zstdWriter.EncodeAll(gobBuffer.Bytes(), nil)
|
||||||
|
|
||||||
err = os.MkdirAll("userdata/"+hexUuid, 0755)
|
err = os.MkdirAll("userdata/"+hexUuid, 0755)
|
||||||
if !os.IsExist(err) {
|
if err != nil && !os.IsExist(err) {
|
||||||
http.Error(w, fmt.Sprintf("failed to create userdata folder: %s", err), http.StatusInternalServerError)
|
http.Error(w, fmt.Sprintf("failed to create userdata folder: %s", err), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -202,13 +202,13 @@ func (s *Server) HandleSavedataDelete(w http.ResponseWriter, r *http.Request) {
|
||||||
switch r.URL.Query().Get("datatype") {
|
switch r.URL.Query().Get("datatype") {
|
||||||
case "0": // System
|
case "0": // System
|
||||||
err := os.Remove("userdata/"+hexUuid+"/system.pzs")
|
err := os.Remove("userdata/"+hexUuid+"/system.pzs")
|
||||||
if !os.IsNotExist(err) {
|
if err != nil && !os.IsNotExist(err) {
|
||||||
http.Error(w, fmt.Sprintf("failed to delete save file: %s", err), http.StatusInternalServerError)
|
http.Error(w, fmt.Sprintf("failed to delete save file: %s", err), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case "1": // Session
|
case "1": // Session
|
||||||
err := os.Remove("userdata/"+hexUuid+"/session.pzs")
|
err := os.Remove("userdata/"+hexUuid+"/session.pzs")
|
||||||
if !os.IsNotExist(err) {
|
if err != nil && !os.IsNotExist(err) {
|
||||||
http.Error(w, fmt.Sprintf("failed to delete save file: %s", err), http.StatusInternalServerError)
|
http.Error(w, fmt.Sprintf("failed to delete save file: %s", err), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue