From bd97ca07e4485aae96db8c4eb819cf2412b5fed8 Mon Sep 17 00:00:00 2001 From: filip Date: Tue, 7 Jul 2020 23:29:28 +0200 Subject: lower the priority of other DL protocols from the same domain --- lib/Downloads.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/Downloads.php b/lib/Downloads.php index a27757ec6..2a4e1f661 100644 --- a/lib/Downloads.php +++ b/lib/Downloads.php @@ -297,6 +297,8 @@ class Downloads 'continent_minus_country' => array(), 'other_continents' => array() ); + $hostnames = array(); + $list_of_mirrs['country_alternate_protocol'] = array(); foreach ($mirs as $curr_continent => $continent_mirrors) { if ($continent != $curr_continent) { @@ -328,13 +330,21 @@ class Downloads } if ($mirrorlist) { - if ($mirror['country'] == $country) - { - $list_of_mirrs['country'][] = $mirror['url']; + $pu = parse_url($mirror['url']); + if (in_array($pu['host'], $hostnames)) { + $list_of_mirrs['country_alternate_protocol'][] = $mirror['url']; } else { - $list_of_mirrs['continent_minus_country'][] = $mirror['url']; + $hostnames[] = $pu['host']; + if ($mirror['country'] == $country) + { + $list_of_mirrs['country'][] = $mirror['url']; + } + else + { + $list_of_mirrs['continent_minus_country'][] = $mirror['url']; + } } } else @@ -371,6 +381,7 @@ class Downloads $resulting_mirrs = array_merge( $list_of_mirrs['country'], $list_of_mirrs['continent_minus_country'], + $list_of_mirrs['country_alternate_protocol'], $list_of_mirrs['other_continents'] ); $one_mirror['mirrors_list'] = array_slice($resulting_mirrs, 0, 10); -- cgit v1.2.1