diff options
Diffstat (limited to 'rhimport/core.go')
-rw-r--r-- | rhimport/core.go | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/rhimport/core.go b/rhimport/core.go index fc92f6a..67d46a4 100644 --- a/rhimport/core.go +++ b/rhimport/core.go @@ -119,6 +119,7 @@ type Context struct { Trusted bool ShowId uint ClearShowCarts bool + ShowCarts []uint GroupName string Cart uint ClearCart bool @@ -185,10 +186,21 @@ func (ctx *Context) SanityCheck() error { if ctx.ShowId != 0 && ctx.ShowId > CART_MAX { return fmt.Errorf("ShowId %d is outside of allowed range (0 < show-id < %d)", ctx.ShowId, CART_MAX) } - if ctx.Cart != 0 && ctx.Cart > CART_MAX { + if err := ctx.getShowInfo(); err != nil { + return err + } + if ctx.Cart == 0 { + return nil + } + if ctx.Cart > CART_MAX { return fmt.Errorf("Cart %d is outside of allowed range (0 < cart < %d)", ctx.Cart, CART_MAX) } - return nil + for _, cart := range ctx.ShowCarts { + if cart == ctx.Cart { + return nil + } + } + return fmt.Errorf("Cart %d is not part of the show with show-id %d", ctx.Cart, ctx.ShowId) } if ctx.GroupName != "" { ismusic, err := ctx.checkMusicGroup() @@ -201,7 +213,7 @@ func (ctx *Context) SanityCheck() error { if ctx.Cart != 0 || ctx.Cut != 0 { return fmt.Errorf("Cart and Cut must not be supplied when importing into a music group") } - return nil + return ctx.getMusicInfo() } if ctx.Cart == 0 { return fmt.Errorf("either ShowId, PoolName or CartNumber must be supplied") @@ -232,8 +244,8 @@ func (ctx *Context) getGroupOfCart() (err error) { return } -func (ctx *Context) getShowInfo() (carts []uint, err error) { - ctx.GroupName, ctx.NormalizationLevel, ctx.AutotrimLevel, carts, err = ctx.db.GetShowInfo(ctx.ShowId) +func (ctx *Context) getShowInfo() (err error) { + ctx.GroupName, ctx.NormalizationLevel, ctx.AutotrimLevel, ctx.ShowCarts, err = ctx.db.GetShowInfo(ctx.ShowId) ctx.Channels = 2 ctx.UseMetaData = true return |