update cart
Build and Publish / BuildAndDeployArm64 (push) Failing after 5s
Build and Publish / BuildAndDeployAmd64 (push) Has been cancelled

This commit is contained in:
2026-06-17 14:16:25 +02:00
parent 11be8aec56
commit ad410d217c
11 changed files with 257 additions and 41 deletions
+20 -4
View File
@@ -219,8 +219,15 @@ func (fs *FileServer) PromotionsHandler(w http.ResponseWriter, r *http.Request)
if r.Method == http.MethodGet {
file, err := os.Open(fileName)
if err != nil {
writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
return
if os.IsNotExist(err) {
_ = os.MkdirAll(filepath.Dir(fileName), 0755)
_ = os.WriteFile(fileName, []byte("{}"), 0644)
file, err = os.Open(fileName)
}
if err != nil {
writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
return
}
}
defer file.Close()
@@ -228,6 +235,7 @@ func (fs *FileServer) PromotionsHandler(w http.ResponseWriter, r *http.Request)
return
}
if r.Method == http.MethodPost {
_ = os.MkdirAll(filepath.Dir(fileName), 0755)
file, err := os.Create(fileName)
if err != nil {
writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
@@ -247,8 +255,15 @@ func (fs *FileServer) VoucherHandler(w http.ResponseWriter, r *http.Request) {
if r.Method == http.MethodGet {
file, err := os.Open(fileName)
if err != nil {
writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
return
if os.IsNotExist(err) {
_ = os.MkdirAll(filepath.Dir(fileName), 0755)
_ = os.WriteFile(fileName, []byte("{}"), 0644)
file, err = os.Open(fileName)
}
if err != nil {
writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
return
}
}
defer file.Close()
@@ -256,6 +271,7 @@ func (fs *FileServer) VoucherHandler(w http.ResponseWriter, r *http.Request) {
return
}
if r.Method == http.MethodPost {
_ = os.MkdirAll(filepath.Dir(fileName), 0755)
file, err := os.Create(fileName)
if err != nil {
writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})