From a90d0409eb21c3feb6d599e56b160c12cba3f376 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sun, 6 Jan 2019 11:23:14 +0100 Subject: Use hash to track connection failed mirrors Signed-off-by: Florian Pritz --- bin/generate-mirror-mail.pl | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/bin/generate-mirror-mail.pl b/bin/generate-mirror-mail.pl index 353c7b0..f73656f 100755 --- a/bin/generate-mirror-mail.pl +++ b/bin/generate-mirror-mail.pl @@ -157,7 +157,6 @@ while () { } my $issues; - my @connection_failed; for my $mirror (@{$json->{urls}}) { next if not $mirror->{active}; @@ -172,7 +171,7 @@ while () { } } else { #if ($mirror->{last_sync} and $mirror->{completion_pct} < 0.9 and $mirror->{completion_pct} > 0) { - push @connection_failed, { + push @{$issues->{connection_failed}}, { url => $mirror->{url}, details_link => $mirror->{details}, protocol => $mirror->{protocol}, @@ -193,27 +192,27 @@ while () { mirror_urls => join("\n", map {${$_}{details_link}} @{$issues->{out_of_sync}}), }, connection_failed => { - mirror_urls => join("\n", map {${$_}{details_link}} @connection_failed), + mirror_urls => join("\n", map {${$_}{details_link}} @{$issues->{connection_failed}}), }, mirror_name => $mirror_name, mirror_url => $url, mail_from_name => $Config->{misc}->{name} // die "misc.name not set in config", ); - my @protocols = uniq map {${$_}{protocol}} @connection_failed; + my @protocols = uniq map {${$_}{protocol}} @{$issues->{connection_failed}}; my @active_urls = grep { $_->{active} } @{$json->{urls}}; if (scalar(@protocols) != scalar(@active_urls)) { $values{connection_failed}->{protocols} = \@protocols; } - if (@{$issues->{out_of_sync}} and @connection_failed) { + if (@{$issues->{out_of_sync}} and @{$issues->{connection_failed}}) { send_template_mail($to, $templates{"multiple-issues"}{"subject"}, $templates{"multiple-issues"}{"template"}, \%values); $sent_mail = 1; } elsif (@{$issues->{out_of_sync}}) { send_template_mail($to, $templates{"out-of-sync"}{"subject"}, $templates{"out-of-sync"}{"template"}, \%values); $sent_mail = 1; - } elsif (@connection_failed) { + } elsif (@{$issues->{connection_failed}}) { send_template_mail($to, $templates{"connection-failed"}{"subject"}, $templates{"connection-failed"}{"template"}, \%values); $sent_mail = 1; } -- cgit v1.2.3-24-g4f1b