summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-07-23 21:47:43 -0500
committerDan McGee <dan@archlinux.org>2012-07-23 21:47:43 -0500
commit9ab460c53a1ac4c79da6f05f2850ee21beedbab2 (patch)
tree02387f2c81200fe799c31a7c3381ade0bc6f741c
parent211340c8bd6ccd6b16f3115a71fce4abedcc4c06 (diff)
downloadarchweb-9ab460c53a1ac4c79da6f05f2850ee21beedbab2.tar.gz
archweb-9ab460c53a1ac4c79da6f05f2850ee21beedbab2.zip
Fall back to 410 Gone for package files view as well
This is another thing that Google and other search engines try to crawl that no longer exists at times, so we should handle it gracefully. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--packages/views/display.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/packages/views/display.py b/packages/views/display.py
index 02f5a5b2..31f18c79 100644
--- a/packages/views/display.py
+++ b/packages/views/display.py
@@ -132,8 +132,16 @@ def group_details(request, arch, name):
def files(request, name, repo, arch):
- pkg = get_object_or_404(Package,
- pkgname=name, repo__name__iexact=repo, arch__name=arch)
+ try:
+ pkg = Package.objects.get(pkgname=name,
+ repo__name__iexact=repo, arch__name=arch)
+ except Package.DoesNotExist:
+ # this may have been deleted recently, so follow the same logic as we
+ # do on the package details page if possible
+ ret = recently_removed_package(request, name, repo, arch)
+ if ret is not None:
+ return ret
+ raise Http404
# files are inserted in sorted order, so preserve that
fileslist = PackageFile.objects.filter(pkg=pkg).order_by('id')
dir_count = sum(1 for f in fileslist if f.is_directory)