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))
|
||||
info, err := os.Stat(path)
|
||||
if err != nil && errors.Is(err, os.ErrNotExist) {
|
||||
// try brace-wrapped filename as fallback
|
||||
alt := filepath.Join(fs.dataDir, fmt.Sprintf("{%d}.events.log", id))
|
||||
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
|
||||
}
|
||||
writeJSON(w, http.StatusNotFound, map[string]string{"error": "cart not found"})
|
||||
return
|
||||
} else if err != nil {
|
||||
writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user