Skip to content

Commit

Permalink
CSAF Downloader: improved ROLIE feed download & CSAF documents mirror
Browse files Browse the repository at this point in the history
  • Loading branch information
giterlizzi committed Oct 17, 2024
1 parent 10b9c86 commit 43de893
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions lib/CSAF/Downloader.pm
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,16 @@ sub _mirror_via_rolie_feed {
my $ua = $self->ua;
my $log = $self->log;

my $res = $ua->get($url);
my $rolie_file = catfile($self->options->directory, URI::URL->new($url)->path);
my $rolie_base_dir = dirname($rolie_file);

if (!$res->is_success) {
$log->error($res->status_line);
Carp::croak $res->message;
}
make_path($rolie_base_dir) unless -e $rolie_base_dir;

$log->debug("Download ROLIE: $url => $rolie_file");

$ua->mirror($url, $rolie_file);

my $rolie = eval { Cpanel::JSON::XS->new->decode($res->content) };
my $rolie = eval { Cpanel::JSON::XS->new->decode(file_read($rolie_file)) };

my $after_date = $self->options->after_date;
my $before_date = $self->options->before_date;
Expand Down Expand Up @@ -196,21 +198,8 @@ sub _mirror_via_provider_metadata {
$log->debug("Use ROLIE feeds");

foreach my $feed (@{$distribution->{rolie}->{feeds}}) {

my $rolie_url = $feed->{url};

$log->debug("ROLIE URL $rolie_url");

my $rolie_file = catfile($self->options->directory, URI::URL->new($rolie_url)->path);
my $rolie_base_dir = dirname($rolie_file);

make_path($rolie_base_dir) unless -e $rolie_base_dir;

$log->debug("Download: $rolie_url => $rolie_file");

$ua->mirror($rolie_url, $rolie_file);
$self->_mirror_via_rolie_feed($rolie_url);

}
}

Expand Down

0 comments on commit 43de893

Please sign in to comment.