summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2017-02-15 19:55:53 +0100
committerAngel Velasquez <angvp@archlinux.org>2017-02-17 12:17:13 -0500
commit644864de28eb8ccf992f90558a25e865d71f80f4 (patch)
tree3e3efa53fa626285e86dfa45c8c1bd0963af8e3b
parent210eb68a41b29915312620f46b0b7e43a84061d2 (diff)
downloadarchweb-644864de28eb8ccf992f90558a25e865d71f80f4.tar.gz
archweb-644864de28eb8ccf992f90558a25e865d71f80f4.zip
Remove scored based mirrorlist sorting
Users may use the returned mirror list as-is without sorting it themselves. This may lead to the first mirror in the list being overloaded. Prevent this by not returning a sorted list. References: https://lists.archlinux.org/pipermail/arch-dev-public/2017-January/028681.html Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r--mirrors/views/mirrorlist.py5
-rw-r--r--templates/mirrors/mirrorlist_generate.html2
-rw-r--r--templates/mirrors/mirrorlist_status.txt4
3 files changed, 6 insertions, 5 deletions
diff --git a/mirrors/views/mirrorlist.py b/mirrors/views/mirrorlist.py
index 3c68d036..0c9c0a7b 100644
--- a/mirrors/views/mirrorlist.py
+++ b/mirrors/views/mirrorlist.py
@@ -10,6 +10,7 @@ from django_countries import countries
from ..models import MirrorUrl, MirrorProtocol
from ..utils import get_mirror_statuses
+import random
class MirrorlistForm(forms.Form):
country = forms.MultipleChoiceField(required=False,
@@ -80,8 +81,8 @@ def status_filter(original_urls):
# (as opposed to those that have been set with no score)
if (u.id not in scores) or (u.score and u.score < 100.0):
urls.append(u)
- # if a url doesn't have a score, treat it as the highest possible
- return sorted(urls, key=lambda x: x.score or 100.0)
+ # randomize list to prevent users from overloading the first mirror in the returned list
+ return random.shuffle(urls)
def find_mirrors(request, countries=None, protocols=None, use_status=False,
diff --git a/templates/mirrors/mirrorlist_generate.html b/templates/mirrors/mirrorlist_generate.html
index 59b0d358..dda3b6c4 100644
--- a/templates/mirrors/mirrorlist_generate.html
+++ b/templates/mirrors/mirrorlist_generate.html
@@ -33,7 +33,7 @@
desired protocol(s). Simply replace the contents of
<code>/etc/pacman.d/mirrorlist</code> with your generated list.
Additionally, the mirror status data can be incorporated into the generated
- mirror list and used to pre-order the mirrors.</p>
+ mirror list and used to only list up to date mirrors.</p>
<form id="list-generator" method="get">
{{ mirrorlist_form.as_div }}
diff --git a/templates/mirrors/mirrorlist_status.txt b/templates/mirrors/mirrorlist_status.txt
index c69075a3..86648fa8 100644
--- a/templates/mirrors/mirrorlist_status.txt
+++ b/templates/mirrors/mirrorlist_status.txt
@@ -5,10 +5,10 @@ forget about where line breaks are happening until you are done getting the
content right, and then go back later to fix it all up.
{% endcomment %}{% autoescape off %}##
## Arch Linux repository mirrorlist
-## Sorted by mirror score from mirror status page
+## Filtered by mirror score from mirror status page
## Generated on {% now "Y-m-d" %}
##
{% for mirror_url in mirror_urls %}
-## Score: {{ mirror_url.score|floatvalue:1|default:'unknown' }}, {{ mirror_url.country.name|default:'Worldwide' }}
+## {{ mirror_url.country.name|default:'Worldwide' }}
#Server = {{ mirror_url.url}}$repo/os/$arch{% endfor %}
{% endautoescape %}