diff options
author | Christian Pointner <equinox@helsinki.at> | 2017-01-11 15:51:39 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2017-01-11 15:57:11 (GMT) |
commit | f986b2d95200eed6f87b2171165e268fc27fad7c (patch) | |
tree | 479f7a2c5c4f33e061cc58c6b24d52267d7cda0f /utils/rhrd-show | |
parent | 6f1430c4bc4216d6c074656a8ac907bd653e9c91 (diff) |
add show group sanity check
Diffstat (limited to 'utils/rhrd-show')
-rwxr-xr-x | utils/rhrd-show | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/utils/rhrd-show b/utils/rhrd-show index 5ed0f4b..0d4ad58 100755 --- a/utils/rhrd-show +++ b/utils/rhrd-show @@ -163,6 +163,30 @@ sub add__check_arguments return 0; } +sub add__check_showgroup +{ + my ($ctx, $groupname) = @_; + + my ($low_cart, $high_cart, $errorstring) = RHRD::rddb::get_group_cart_range($ctx, $groupname); + unless(defined $low_cart) { + print STDERR "$errorstring\n"; + return 1; + } + + (my $shows_low_cart, my $shows_high_cart, $errorstring) = RHRD::rddb::get_shows_cart_range($ctx); + unless(defined $shows_low_cart) { + print STDERR "$errorstring\n"; + return 1; + } + + if($shows_low_cart > $low_cart || $shows_high_cart < $high_cart) { + print STDERR "group '" . $groupname . "' already exists but is not a show group\n"; + return 1; + } + + return 0; +} + sub add { my ($ctx, $groupname, $name, $title, $num_carts, $rhythm, $dow, $starttime, $len, $type) = @_; @@ -173,8 +197,6 @@ sub add } ($dow, undef, undef) = RHRD::utils::cmdline_dow($dow); - print " * creating show: " . $title . " (" . $name . ") for group '" . $groupname . "'\n"; - my ($result, $status, $errorstring) = RHRD::rddb::check_group($ctx, $groupname); unless(defined $result) { print STDERR $status . ": " . $errorstring . "\n"; @@ -183,10 +205,14 @@ sub add my $low_cart = 0; if($result) { - print " * using existing group '" . $groupname . "'\n"; + my $ret = add__check_showgroup($ctx, $groupname); + if($ret) { + return $ret; + } + print " * creating show: " . $title . " (" . $name . ") using existing group '" . $groupname . "'\n"; ($low_cart, $status, $errorstring) = RHRD::rddb::get_next_free_show_group_carts($ctx, $groupname, $num_carts); } else { - print " * '" . $groupname . "' does not exist - creating it\n"; + print " * creating show: " . $title . " (" . $name . ") using new group '" . $groupname . "'\n"; ($low_cart, $status, $errorstring) = RHRD::rddb::create_show_group($ctx, $groupname); } unless(defined $low_cart) { |