Prevent KeyError when thumbnail has no link.

This can happen when the link isn't refreshing properly. It's better to
show an empty thumbnail than a 500 Internal Server Error.
This commit is contained in:
2016-05-31 17:57:08 +02:00
parent 4b028d85c9
commit 03fab52da2

View File

@@ -71,7 +71,10 @@ class File(List, Find, Create, Post, Update, Delete, Replace):
thumbnail = next((item for item in self['variations']
if item['size'] == size), None)
if thumbnail:
return thumbnail['link']
try:
return thumbnail['link']
except KeyError:
return None
if self.link:
root, ext = os.path.splitext(self.link)