double check if poster does not exist if it was created async

This commit is contained in:
j 2013-01-29 07:19:57 +05:30
commit b43a6cf647
2 changed files with 11 additions and 1 deletions

View file

@ -708,6 +708,16 @@ def poster(request, id, size=None):
item = get_object_or_404(models.Item, itemId=id)
if not item.access(request.user):
return HttpResponseForbidden()
if not item.poster:
poster_path = os.path.join(settings.MEDIA_ROOT, item.path('poster.jpg'))
if os.path.exists(poster_path):
item.poster.name = item.path('poster.jpg')
models.Item.objects.filter(pk=item.id).update(
poster=item.poster.name,
poster_height=item.poster.height,
poster_width=item.poster.width,
icon=item.icon.name
)
if item.poster:
return image_to_response(item.poster, size)
else: