From d4a3f51f6a280b7b5d805392da2b348ea3b30b59 Mon Sep 17 00:00:00 2001 From: "Andreas J. Koenig" Date: Sat, 27 Sep 2008 14:19:09 +0200 Subject: [PATCH] protect overview() a bit better against inexistent files which before this operation spit zillions of unini warnings and wrote crap --- lib/File/Rsync/Mirror/Recent.pm | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/lib/File/Rsync/Mirror/Recent.pm b/lib/File/Rsync/Mirror/Recent.pm index 4e333d2..805a8f6 100644 --- a/lib/File/Rsync/Mirror/Recent.pm +++ b/lib/File/Rsync/Mirror/Recent.pm @@ -239,24 +239,29 @@ sub overview { my($self) = @_; my $rfs = $self->recentfiles; my(@s,%rank); - for my $rf (@$rfs) { + RECENTFILE: for my $rf (@$rfs) { my $re=$rf->recent_events; - my $span = $re->[0]{epoch}-$re->[-1]{epoch}; - my $rfsummary = - [ - $rf->interval, - scalar @$re, - sprintf ("%.3f", $re->[0]{epoch}), - sprintf ("%.3f", $re->[-1]{epoch}), - sprintf ("%.3f", $span), - ($rf->interval eq "Z" - ? - "-" - : - sprintf ("%5.1f%%", 100 * $span / $rf->interval_secs) - ), - ]; - @rank{@{$rfsummary}[2,3]} = (); + my $rfsummary; + if (@$re) { + my $span = $re->[0]{epoch}-$re->[-1]{epoch}; + $rfsummary = + [ + $rf->interval, + scalar @$re, + sprintf ("%.3f", $re->[0]{epoch}), + sprintf ("%.3f", $re->[-1]{epoch}), + sprintf ("%.3f", $span), + ($rf->interval eq "Z" + ? + "-" + : + sprintf ("%5.1f%%", 100 * $span / $rf->interval_secs) + ), + ]; + @rank{@{$rfsummary}[2,3]} = (); + } else { + next RECENTFILE; + } push @s, $rfsummary; } @rank{sort {$b <=> $a} keys %rank} = 1..keys %rank; -- 2.11.4.GIT