dont fail on broken images
This commit is contained in:
parent
4d958067fe
commit
a26569d23e
1 changed files with 5 additions and 3 deletions
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue