[ckan-changes] commit/ckanext-storage: rgrp: [controller/file][s]: handle storage file urls which do not exist with redirect where trailing slash or 404 (fixes #1195).
Bitbucket
commits-noreply at bitbucket.org
Thu Jul 28 08:23:57 UTC 2011
1 new changeset in ckanext-storage:
http://bitbucket.org/okfn/ckanext-storage/changeset/49734285f1ef/
changeset: 49734285f1ef
user: rgrp
date: 2011-07-28 10:23:49
summary: [controller/file][s]: handle storage file urls which do not exist with redirect where trailing slash or 404 (fixes #1195).
affected #: 1 file (433 bytes)
--- a/ckanext/storage/controller.py Thu May 26 11:57:00 2011 +0100
+++ b/ckanext/storage/controller.py Thu Jul 28 09:23:49 2011 +0100
@@ -341,6 +341,18 @@
return render('ckanext/storage/success.html')
def file(self, label):
+ exists = self.ofs.exists(BUCKET, label)
+ if not exists:
+ # handle erroneous trailing slash by redirecting to url w/o slash
+ if label.endswith('/'):
+ label = label[:-1]
+ file_url = h.url_for(
+ 'storage_file',
+ label=label
+ )
+ h.redirect_to(file_url)
+ else:
+ abort(404)
file_url = self.ofs.get_url(BUCKET, label)
if file_url.startswith("file://"):
metadata = self.ofs.get_metadata(BUCKET, label)
Repository URL: https://bitbucket.org/okfn/ckanext-storage/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the ckan-changes
mailing list