diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/MGA/Advisories.pm | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/lib/MGA/Advisories.pm b/lib/MGA/Advisories.pm index 3752250..c7248b8 100644 --- a/lib/MGA/Advisories.pm +++ b/lib/MGA/Advisories.pm @@ -12,6 +12,7 @@ use Email::Simple::Creator; use Fcntl qw(SEEK_END); use HTTP::Request; use LWP::UserAgent; +use MCE::Map; use Parallel::ForkManager; use File::Basename; use XMLRPC::Lite; @@ -171,23 +172,36 @@ sub login_bz { return 0; } +# Load the advisory and its status and return both the filename and advisory contents +sub read_adv { + my ($advfile) = @_; + my $adv; + eval { + $adv = LoadFile($advfile); + }; + if ($adv) { + $adv->{ref} = basename($advfile, ".adv"); + if ($adv->{ID}) { + my $statusfile = status_file($adv->{ID}); + $adv->{status} = -f $statusfile ? LoadFile($statusfile) : {}; + } + } + return [$advfile, $adv]; +} sub get_advisories_from_dir { # Retrieve last modified dates from SVN my $modified = get_modified(); my %advisories; - foreach my $advfile (glob "$config->{advisories_dir}/*.adv") { - my $adv; - eval { - $adv = LoadFile($advfile); - }; - if ($@) { + # Read all advisories in parallel + foreach my $advdata (mce_map {read_adv($_)} glob "$config->{advisories_dir}/*.adv") { + my ($advfile, $adv) = @$advdata; + if (!$adv) { print "Failed to load $advfile\n"; print $@; next; } - $adv->{ref} = basename($advfile, ".adv"); if (!$adv->{ID}) { next unless $config->{mode} eq 'qa'; $adv->{ID} = next_id('TODO', keys %advisories); @@ -197,10 +211,16 @@ sub get_advisories_from_dir { report_exit("Unknown type $adv->{type}") unless $config->{advisory_types}{$adv->{type}}; $advisories{$adv->{ID}} = $adv; - my $statusfile = status_file($adv->{ID}); - $adv->{status} = -f $statusfile ? LoadFile($statusfile) : {}; + if (!$adv->{status}) { + # If it isn't already loaded + my $statusfile = status_file($adv->{ID}); + $adv->{status} = -f $statusfile ? LoadFile($statusfile) : {}; + } + # TODO: this changes the ref set previously to include the extension + # this time. Is that deliberate? my $fn = $adv->{ref} = basename($advfile); - if (exists $modified->{$fn}) { + if (exists $modified->{$fn} && + (! exists $adv->{status}{modified} || $modified->{$fn} > $adv->{status}{modified})) { # Pull the modified date into the advisory $adv->{status}{modified} = $modified->{$fn}; } @@ -376,6 +396,9 @@ sub assign_id { print $msg = "✔ "; } else { print $msg = "✘ ($rel/$media/$srpm) "; + if ($media ne "core" && index($srpm, ".$media") < 0) { + print $msg .= "(missing .$media suffix?) "; + } $failed = 1; } $buffer .= $msg; |