summaryrefslogtreecommitdiff
path: root/rhimport
diff options
context:
space:
mode:
Diffstat (limited to 'rhimport')
-rw-r--r--rhimport/importer.go25
1 files changed, 17 insertions, 8 deletions
diff --git a/rhimport/importer.go b/rhimport/importer.go
index 4473ee4..73d446e 100644
--- a/rhimport/importer.go
+++ b/rhimport/importer.go
@@ -393,20 +393,29 @@ func clearShowCarts(ctx *Context, res *Result, carts []uint) (err error) {
}
func addShowCartCut(ctx *Context, res *Result, carts []uint) (err error) {
- if err = addCart(ctx, res); err != nil || res.ResponseCode != http.StatusOK {
- return
+ if ctx.Cart != 0 {
+ return addCartCut(ctx, res)
}
+
for _, cart := range carts {
- if cart == ctx.Cart {
- if err = addCut(ctx, res); err != nil || res.ResponseCode != http.StatusOK {
- return removeCart(ctx, &Result{ResponseCode: http.StatusOK})
+ ctx.Cart = cart
+ if err = addCart(ctx, res); err != nil {
+ return
+ }
+ switch res.ResponseCode {
+ case http.StatusOK:
+ {
+ if err = addCut(ctx, res); err != nil || res.ResponseCode != http.StatusOK {
+ return removeCart(ctx, &Result{ResponseCode: http.StatusOK})
+ }
+ return
}
+ case http.StatusForbidden: // Cart already exists
+ continue
+ default:
return
}
}
- if err = removeCart(ctx, res); err != nil || res.ResponseCode != http.StatusOK {
- return
- }
res.ResponseCode = http.StatusForbidden
res.ErrorString = fmt.Sprintf("Show %d has no free carts left", ctx.ShowId)
return