fix
This commit is contained in:
@@ -153,19 +153,8 @@ func (fs *FileServer) CartHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
path := filepath.Join(fs.dataDir, fmt.Sprintf("%d.events.log", id))
|
path := filepath.Join(fs.dataDir, fmt.Sprintf("%d.events.log", id))
|
||||||
info, err := os.Stat(path)
|
info, err := os.Stat(path)
|
||||||
if err != nil && errors.Is(err, os.ErrNotExist) {
|
if err != nil && errors.Is(err, os.ErrNotExist) {
|
||||||
// try brace-wrapped filename as fallback
|
writeJSON(w, http.StatusNotFound, map[string]string{"error": "cart not found"})
|
||||||
alt := filepath.Join(fs.dataDir, fmt.Sprintf("{%d}.events.log", id))
|
return
|
||||||
if fi, err2 := os.Stat(alt); err2 == nil {
|
|
||||||
path = alt
|
|
||||||
info = fi
|
|
||||||
} else {
|
|
||||||
if errors.Is(err2, os.ErrNotExist) {
|
|
||||||
writeJSON(w, http.StatusNotFound, map[string]string{"error": "cart not found"})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err2.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
|
writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user