Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2019-11-04 09:09:03 +0100
committerErich Eckner <git@eckner.net>2019-11-04 09:09:40 +0100
commite50fe76394d3d35f75587795af220682ffbe74f9 (patch)
tree791bec4b40645f20279be1b0aa95166a77c63f42
parenta674e136827d1d2a6459402ce634080011127ee7 (diff)
mirrors.php: avoid division by 0
-rw-r--r--mirrors.php7
1 files changed, 5 insertions, 2 deletions
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);