mirror of
https://github.com/jazzband/django-avatar.git
synced 2026-03-16 22:20:30 +00:00
Prevent thumbnails clones
To prevent the creation of multiple thumbnails clones "fileName.hash.ext"
This commit is contained in:
parent
206682ce0a
commit
d7db61b275
1 changed files with 5 additions and 1 deletions
|
|
@ -111,7 +111,11 @@ class Avatar(models.Model):
|
|||
thumb_file = ContentFile(thumb.getvalue())
|
||||
else:
|
||||
thumb_file = File(orig)
|
||||
thumb = self.avatar.storage.save(self.avatar_name(size), thumb_file)
|
||||
storage = self.avatar.storage
|
||||
thum_name = self.avatar_name(size)
|
||||
if storage.exists(thum_name):
|
||||
storage.delete(thum_name)
|
||||
storage.save(thum_name, thumb_file)
|
||||
except IOError:
|
||||
return # What should we do here? Render a "sorry, didn't work" img?
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue