Don't save Document in pre_delete handler (fixes #2889)

FileField.delete() will, by default, save() the model instance it is
attached to. This is pointless if we're in the process of deleting the
Document -- and since Document.save() calls Document.update_matches(),
this scans all annotations every time a document is deleted.
This commit is contained in:
Will Thompson 2016-02-26 11:00:21 +00:00 committed by j
parent 7d99950942
commit 6e0049a20c

View file

@ -302,7 +302,7 @@ def delete_document(sender, **kwargs):
for f in glob('%s/*' % folder): for f in glob('%s/*' % folder):
if f != t.file.path: if f != t.file.path:
os.unlink(f) os.unlink(f)
t.file.delete() t.file.delete(save=False)
pre_delete.connect(delete_document, sender=Document) pre_delete.connect(delete_document, sender=Document)
class ItemProperties(models.Model): class ItemProperties(models.Model):