Catch KeyError in download function

This change is necessary to avoid an error ticket when you delete an upload field from a table (and also from the model definition). In those cases, requests to old URLs will throw a KeyError. With this fix, those requests return 404 as expected.

Also, catching AttributeError is still necessary for the situation when the table is removed entirely. If an old request come in, that sentence will throw an AttributeError, that will be catched properly, and request will return 404.
This commit is contained in:
Lisandro authored and GitHub committed 2018-06-15 08:30:44 -03:00
1 parent d7624b95f8
commit 911cf430a9
1 file changed
+1 -1
+1 -1
View File
@@ -667,7 +667,7 @@ class Response(Storage):
(t, f) = (items.group('table'), items.group('field'))
try:
field = db[t][f]
except AttributeError:
except (AttributeError, KeyError):
raise HTTP(404)
try:
(filename, stream) = field.retrieve(name, nameonly=True)