summaryrefslogtreecommitdiff
path: root/packages/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/views.py')
-rw-r--r--packages/views.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/packages/views.py b/packages/views.py
index 8c9c1b18..79793355 100644
--- a/packages/views.py
+++ b/packages/views.py
@@ -548,15 +548,21 @@ def flag_confirmed(request, name, repo, arch):
def download(request, name, repo, arch):
pkg = get_object_or_404(Package,
pkgname=name, repo__name__iexact=repo, arch__name=arch)
- mirrorurl = MirrorUrl.objects.filter(mirror__country='Any',
+ mirror_urls = MirrorUrl.objects.filter(
mirror__public=True, mirror__active=True,
- protocol__protocol__iexact='HTTP')[0]
+ protocol__protocol__iexact='HTTP')
+ # look first for an 'Any' URL, then fall back to any HTTP URL
+ filtered_urls = mirror_urls.filter(mirror__country='Any')[:1]
+ if not filtered_urls:
+ filtered_urls = mirror_urls[:1]
+ if not filtered_urls:
+ raise Http404
arch = pkg.arch.name
if pkg.arch.agnostic:
# grab the first non-any arch to fake the download path
arch = Arch.objects.exclude(agnostic=True)[0].name
values = {
- 'host': mirrorurl.url,
+ 'host': filtered_urls[0].url,
'arch': arch,
'repo': pkg.repo.name.lower(),
'file': pkg.filename,