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>
This commit is contained in:
parent
210eb68a41
commit
644864de28
@ -10,6 +10,7 @@
|
||||
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,
|
||||
|
@ -33,7 +33,7 @@ <h3>Customized by country mirrorlist</h3>
|
||||
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 }}
|
||||
|
@ -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 %}
|
||||
|
Loading…
Reference in New Issue
Block a user