From 6e0049a20c8476dde978227a8c49e42bcca2d1d3 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Fri, 26 Feb 2016 11:00:21 +0000 Subject: [PATCH] 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. --- pandora/document/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora/document/models.py b/pandora/document/models.py index 26e97e71..69c9df17 100644 --- a/pandora/document/models.py +++ b/pandora/document/models.py @@ -302,7 +302,7 @@ def delete_document(sender, **kwargs): for f in glob('%s/*' % folder): if f != t.file.path: os.unlink(f) - t.file.delete() + t.file.delete(save=False) pre_delete.connect(delete_document, sender=Document) class ItemProperties(models.Model):