diff options
author | Christian Pointner <equinox@helsinki.at> | 2010-04-29 12:00:00 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2010-04-29 12:00:00 (GMT) |
commit | 98323c1bf0d2b9c4f0b60e8dc256a15911602b6b (patch) | |
tree | 11d98da6b911fd46b3b86e392f72edf0249ab9c0 /rhimport.pm | |
parent | db51fc7641c5c3c7055df8424a85e8c55dceb7cd (diff) |
check size if playlist before import
Diffstat (limited to 'rhimport.pm')
-rw-r--r-- | rhimport.pm | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/rhimport.pm b/rhimport.pm index 6597fb4..7ecc2fe 100644 --- a/rhimport.pm +++ b/rhimport.pm @@ -108,6 +108,14 @@ sub get_used_carts return @carts; } +sub get_num_carts +{ + my ($dbh, $group) = @_; + + my ($low_cart, $high_cart) = get_cart_range($dbh, $group); + return $high_cart - $low_cart + 1; +} + sub clear_carts { my ($dbh, $group, $to_cart, $progress_cb) = @_; @@ -150,7 +158,7 @@ sub clear_carts sub import_playlist { - my ($playlist, $dropbox, $user, $progress_cb, $error_cb) = @_; + my ($playlist, $dropbox, $user, $num_carts, $progress_cb, $error_cb) = @_; print "Starting import from playlist $playlist to $dropbox"; my @entries; @@ -165,10 +173,21 @@ sub import_playlist } close(FILE); my $num_entries = scalar(@entries); - print " ($num_entries Files in list)\n"; - + print " ($num_entries Files in list -> $num_carts available)\n"; + + if($num_carts < $num_entries) { + if($error_cb) { + my $ret = $error_cb->("Achtung!\nDie Playlist beinhaltet mehr als $num_carts Dateien. Es werden nur die ersten $num_carts Dateien importiert."); + if(!$ret) { + return 0, "too many files in playlist"; + } + + $#entries = $num_carts-1; + $num_entries = scalar(@entries); + } + } + print "will import $num_entries files\n"; - return (0, ""); my $cnt = 0; my $ret = 0; my $log = ""; |