summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2019-01-06 11:22:09 +0100
committerFlorian Pritz <bluewind@xinu.at>2019-01-06 11:22:09 +0100
commit1c1f5442f9c10482479596c202522994a523c75a (patch)
tree797a07408f1222b6e324da36a8a47e28d7bf307e
parent01f6e852fd65f2b373b0c56955726a44c0e4538d (diff)
downloadarch-mirror-tools-1c1f5442f9c10482479596c202522994a523c75a.tar.gz
arch-mirror-tools-1c1f5442f9c10482479596c202522994a523c75a.tar.xz
Use hash to track out of sync mirrors
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rwxr-xr-xbin/generate-mirror-mail.pl12
1 files changed, 6 insertions, 6 deletions
diff --git a/bin/generate-mirror-mail.pl b/bin/generate-mirror-mail.pl
index d1fe6df..353c7b0 100755
--- a/bin/generate-mirror-mail.pl
+++ b/bin/generate-mirror-mail.pl
@@ -156,7 +156,7 @@ while (<STDIN>) {
die "Admin email not set in mirror json. Login problem?" unless defined $json->{admin_email};
}
- my @out_of_sync;
+ my $issues;
my @connection_failed;
for my $mirror (@{$json->{urls}}) {
@@ -164,7 +164,7 @@ while (<STDIN>) {
if ($mirror->{last_sync}) {
my $time = str2time($mirror->{last_sync});
if ($time < time() - 60*60*24*3) {
- push @out_of_sync, {
+ push @{$issues->{out_of_sync}}, {
time => $time,
url => $mirror->{url},
details_link => $mirror->{details},
@@ -181,7 +181,7 @@ while (<STDIN>) {
}
# extract and deduplicate sync times
- my @last_sync = keys %{{ map { ${$_}{time} => 1 } @out_of_sync }};
+ my @last_sync = keys %{{ map { ${$_}{time} => 1 } @{$issues->{out_of_sync}} }};
my $sent_mail = 0;
my $to = $json->{admin_email};
@@ -190,7 +190,7 @@ while (<STDIN>) {
my %values = (
out_of_sync => {
last_sync => join(", ", map {time2str("%Y-%m-%d", $_)} @last_sync),
- mirror_urls => join("\n", map {${$_}{details_link}} @out_of_sync),
+ mirror_urls => join("\n", map {${$_}{details_link}} @{$issues->{out_of_sync}}),
},
connection_failed => {
mirror_urls => join("\n", map {${$_}{details_link}} @connection_failed),
@@ -207,10 +207,10 @@ while (<STDIN>) {
}
- if (@out_of_sync and @connection_failed) {
+ if (@{$issues->{out_of_sync}} and @connection_failed) {
send_template_mail($to, $templates{"multiple-issues"}{"subject"}, $templates{"multiple-issues"}{"template"}, \%values);
$sent_mail = 1;
- } elsif (@out_of_sync) {
+ } 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) {