summaryrefslogtreecommitdiff
path: root/mirrors
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2013-05-31 19:21:47 -0500
committerDan McGee <dan@archlinux.org>2013-05-31 19:21:47 -0500
commite50471b9a7658f37b00aa3854d75a45007926802 (patch)
treeef31774ad11960b590dffa59c5bcf4d78c50c0dc /mirrors
parentbbeb9276051c2dc34f6d63fac4963343aacdf9b2 (diff)
Honor mirror URL active attribute in several places
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'mirrors')
-rw-r--r--mirrors/management/commands/mirrorcheck.py2
-rw-r--r--mirrors/management/commands/mirrorresolv.py2
-rw-r--r--mirrors/utils.py10
-rw-r--r--mirrors/views.py7
4 files changed, 14 insertions, 7 deletions
diff --git a/mirrors/management/commands/mirrorcheck.py b/mirrors/management/commands/mirrorcheck.py
index e7dd7b49..6faf294a 100644
--- a/mirrors/management/commands/mirrorcheck.py
+++ b/mirrors/management/commands/mirrorcheck.py
@@ -63,7 +63,7 @@ class Command(NoArgsCommand):
timeout = options.get('timeout')
urls = MirrorUrl.objects.select_related('protocol').filter(
- mirror__active=True, mirror__public=True)
+ active=True, mirror__active=True, mirror__public=True)
location = options.get('location', None)
if location:
diff --git a/mirrors/management/commands/mirrorresolv.py b/mirrors/management/commands/mirrorresolv.py
index a6c2523e..85a3c654 100644
--- a/mirrors/management/commands/mirrorresolv.py
+++ b/mirrors/management/commands/mirrorresolv.py
@@ -39,7 +39,7 @@ class Command(NoArgsCommand):
def resolve_mirrors():
logger.debug("requesting list of mirror URLs")
- for mirrorurl in MirrorUrl.objects.filter(mirror__active=True):
+ for mirrorurl in MirrorUrl.objects.filter(active=True, mirror__active=True):
try:
# save old values, we can skip no-op updates this way
oldvals = (mirrorurl.has_ipv4, mirrorurl.has_ipv6)
diff --git a/mirrors/utils.py b/mirrors/utils.py
index ba45da5f..e98b5c9f 100644
--- a/mirrors/utils.py
+++ b/mirrors/utils.py
@@ -116,7 +116,10 @@ def annotate_url(url, url_data):
def get_mirror_statuses(cutoff=DEFAULT_CUTOFF, mirror_id=None):
cutoff_time = now() - cutoff
- valid_urls = MirrorUrl.objects.filter(
+ # TODO: this prevents grabbing data points from any mirror that was active,
+ # receiving checks, and then marked private. we can probably be smarter and
+ # filter the data later?
+ valid_urls = MirrorUrl.objects.filter(active=True,
mirror__active=True, mirror__public=True,
logs__check_time__gte=cutoff_time).distinct()
@@ -159,7 +162,7 @@ def get_mirror_statuses(cutoff=DEFAULT_CUTOFF, mirror_id=None):
def get_mirror_errors(cutoff=DEFAULT_CUTOFF, mirror_id=None):
cutoff_time = now() - cutoff
errors = MirrorLog.objects.filter(
- is_success=False, check_time__gte=cutoff_time,
+ is_success=False, check_time__gte=cutoff_time, url__active=True,
url__mirror__active=True, url__mirror__public=True).values(
'url__url', 'url__country', 'url__protocol__protocol',
'url__mirror__tier', 'error').annotate(
@@ -189,13 +192,14 @@ def get_mirror_url_for_download(cutoff=DEFAULT_CUTOFF):
min_sync_time = status_data['last_sync__max'] - timedelta(minutes=20)
best_logs = MirrorLog.objects.filter(is_success=True,
check_time__gte=min_check_time, last_sync__gte=min_sync_time,
+ url__active=True,
url__mirror__public=True, url__mirror__active=True,
url__protocol__default=True).order_by(
'duration')[:1]
if best_logs:
return MirrorUrl.objects.get(id=best_logs[0].url_id)
- mirror_urls = MirrorUrl.objects.filter(
+ mirror_urls = MirrorUrl.objects.filter(active=True,
mirror__public=True, mirror__active=True, protocol__default=True)
# look first for a country-agnostic URL, then fall back to any HTTP URL
filtered_urls = mirror_urls.filter(country='')[:1]
diff --git a/mirrors/views.py b/mirrors/views.py
index 22eb57b8..91cf6750 100644
--- a/mirrors/views.py
+++ b/mirrors/views.py
@@ -40,10 +40,13 @@ class MirrorlistForm(forms.Form):
fields['protocol'].choices = protos
fields['protocol'].initial = [p.protocol for p in initial]
fields['ip_version'].initial = ['4']
+ locations = [(l.id, l.source_ip) for l in
+ CheckLocation.objects.all()]
+ fields['check_location'].choices = locations
def get_countries(self):
country_codes = set()
- country_codes.update(MirrorUrl.objects.filter(
+ country_codes.update(MirrorUrl.objects.filter(active=True,
mirror__active=True).exclude(country='').values_list(
'country', flat=True).order_by().distinct())
countries = [(code, self.countries[code]) for code in country_codes]
@@ -102,7 +105,7 @@ def find_mirrors(request, countries=None, protocols=None, use_status=False,
else:
protocols = MirrorProtocol.objects.filter(protocol__in=protocols)
qset = MirrorUrl.objects.select_related().filter(
- protocol__in=protocols,
+ protocol__in=protocols, active=True,
mirror__public=True, mirror__active=True)
if countries and 'all' not in countries:
qset = qset.filter(country__in=countries)