View | Details | Raw Unified | Return to bug 40748
Collapse All | Expand All

(-)a/misc/cronjobs/social_data/update_social_data.pl (-9 / +17 lines)
Lines 5-17 use Modern::Perl; Link Here
5
use Koha::Script -cron;
5
use Koha::Script -cron;
6
use C4::Context;
6
use C4::Context;
7
use C4::SocialData;
7
use C4::SocialData;
8
use URI;
8
9
9
my $url             = quotemeta( C4::Context->preference("Babeltheque_url_update") );
10
my $syspref_value = C4::Context->preference("Babeltheque_url_update");
10
my $output_dir      = qq{/tmp};
11
my $url           = URI->new($syspref_value);
11
my $output_filepath = qq{$output_dir/social_data.csv};
12
system(qq{/bin/rm -f $output_filepath});
13
system(qq{/bin/rm -f $output_dir/social_data.csv.bz2});
14
system(qq{/usr/bin/wget $url -O $output_dir/social_data.csv.bz2 }) == 0 or die "Can't get bz2 file from url $url ($?)";
15
system(qq{/bin/bunzip2 $output_dir/social_data.csv.bz2 }) == 0          or die "Can't extract bz2 file ($?)";
16
12
17
C4::SocialData::update_data $output_filepath;
13
#NOTE: Both HTTP and HTTPS URLs are instances of the URI::http class
14
if ( $url && ref $url && $url->isa('URI::http') ) {
15
    my $output_dir      = qq{/tmp};
16
    my $output_filepath = qq{$output_dir/social_data.csv};
17
    system(qq{/bin/rm -f $output_filepath});
18
    system(qq{/bin/rm -f $output_dir/social_data.csv.bz2});
19
    system( '/usr/bin/wget', $url, '-O', "$output_dir/social_data.csv.bz2" ) == 0
20
        or die "Can't get bz2 file from url $url ($?)";
21
    system(qq{/bin/bunzip2 $output_dir/social_data.csv.bz2 }) == 0 or die "Can't extract bz2 file ($?)";
22
23
    C4::SocialData::update_data $output_filepath;
24
} else {
25
    print "$syspref_value is not a HTTP URL. Aborting.\n";
26
}
18
- 

Return to bug 40748