Skip to content
This repository has been archived by the owner on Jun 1, 2022. It is now read-only.

Commit

Permalink
geoipupdate-pureperl.pl: On error, do not abort - go on with the next…
Browse files Browse the repository at this point in the history
… product
  • Loading branch information
borisz committed Feb 19, 2013
1 parent 07397e5 commit 18d026b
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions apps/geoipupdate-pureperl.pl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
use strict;
use warnings;

our $VERSION = '0.07';
our $VERSION = '0.08';

use 5.008;
use Data::Dumper;
Expand Down Expand Up @@ -106,6 +106,20 @@
print "Product ids @product_ids\n";
}

my $err_cnt = 0;

my $print_on_error = sub {
my $err = shift;
return unless $err;
if ( $err !~ /^No new updates available/i ) {
print STDERR $err, $/;
$err_cnt++;
}
else {
print $err;
}
};

if ($user_id) {
for my $product_id (@product_ids) {

Expand All @@ -117,22 +131,18 @@
$product_id, $opts{v}
);
};
my $err = $@;
die $err if $err and $err !~ /^No new updates available/i;
print $err;
$print_on_error->($@);
}
}
else {

# Old format with just license key for MaxMind GeoIP Country database updates
# here for backwards compatibility
eval { GeoIP_update_database( $license_key, $opts{v} ); };
my $err = $@;
die $err if $err and $err !~ /^No new updates available/i;
print $err;
$print_on_error->($@);
}

exit 0;
exit( $err_cnt > 0 ? 1 : 0 );

sub GeoIP_update_database_general {
my ( $user_id, $license_key, $product_id, $verbose, $client_ipaddr ) = @_;
Expand Down

0 comments on commit 18d026b

Please sign in to comment.