cleanup document thumbnails

This commit is contained in:
j 2014-02-02 06:35:04 +00:00
parent 167de4cc97
commit 17586c1d2a

View file

@ -287,10 +287,10 @@ class Document(models.Model):
def delete_document(sender, **kwargs): def delete_document(sender, **kwargs):
t = kwargs['instance'] t = kwargs['instance']
if t.file: if t.file:
if t.extension == 'pdf': folder = os.path.dirname(self.file.path)
thumb = t.thumbnail() for f in glob('%s/*' % folder):
if os.path.exists(thumb): if f != self.file.path:
os.unlink(thumb) os.unlink(f)
t.file.delete() t.file.delete()
pre_delete.connect(delete_document, sender=Document) pre_delete.connect(delete_document, sender=Document)