From e50fe76394d3d35f75587795af220682ffbe74f9 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 4 Nov 2019 09:09:03 +0100 Subject: mirrors.php: avoid division by 0 --- mirrors.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'mirrors.php') diff --git a/mirrors.php b/mirrors.php index feffc9a..0a57ce6 100644 --- a/mirrors.php +++ b/mirrors.php @@ -216,8 +216,11 @@ if ($uri_parts[0] == 'status') { ) as $key) $row[$key] = floatval($row[$key]); $row["last_sync"] = gmdate("Y-m-d\TH:i:s\Z", $row["last_sync"]); - $row["score"] = - ($row["delay"] + $row["duration_avg"] + $row["duration_stddev"]) / $row["completion_pct"]; + if ($row["completion_pct"] == 0) + $row["score"] = 0; + else + $row["score"] = + ($row["delay"] + $row["duration_avg"] + $row["duration_stddev"]) / $row["completion_pct"]; $urls[] = $row; $last_check = max ($row["start"], $last_check); $max_count = max ($row["count"], $max_count); -- cgit v1.2.3