forked from 0x2620/pandora
cleanup document thumbnails
This commit is contained in:
parent
167de4cc97
commit
17586c1d2a
1 changed files with 4 additions and 4 deletions
|
@ -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)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue