dont fail on broken images

This commit is contained in:
j 2011-10-31 01:34:28 +01:00
parent 4d958067fe
commit a26569d23e

View file

@ -68,6 +68,9 @@ class PosterCache(models.Model):
status = models.CharField(max_length=1024, default='200')
failed = models.BooleanField(default=False)
def __unicode__(self):
return u'%s' % self.url
def get(self):
if not self.image and not self.failed:
import ox.net
@ -91,12 +94,11 @@ class PosterCache(models.Model):
if self.image:
try:
self.image.width
except IOError:
self.image.delete()
except TypeError:
except:
self.failed = True
self.status = "invalid image"
self.image.delete()
self.save()
return self.image
class Poster(models.Model):