Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Revert deleting image redentions

Pacu21e741a0f9691
diff --git a/docs/architecture/thumbnails.rst b/docs/architecture/thumbnails.rst
index 422717ff26..32a9a60472 100644
--- a/docs/architecture/thumbnails.rst
+++ b/docs/architecture/thumbnails.rst
@@ -18,8 +18,8 @@ Create missing thumbnails for all ProductImage instances.
$ python manage.py create_thumbnails
-Deleting Image Renditions
--------------------------
+Deleting Images
+---------------
-Image renditions are not deleted automatically with the main image, however Saleor handles that on ``post_delete`` model's signal.
-More on deleting rendition images can be found in `VersatileImageField documentation <https://django-versatileimagefield.readthedocs.io/en/latest/deleting_created_images.html>`_
+Image renditions are not deleted automatically with the Image instance, so is the main image.
+More on deleting images can be found in `VersatileImageField documentation <https://django-versatileimagefield.readthedocs.io/en/latest/deleting_created_images.html>`_
diff --git a/saleor/product/models.py b/saleor/product/models.py
index 65d9d61275..bda70fa3a9 100644
--- a/saleor/product/models.py
+++ b/saleor/product/models.py
@@ -393,15 +393,6 @@ class ProductImage(models.Model):
super().delete(*args, **kwargs)
-@receiver(models.signals.post_delete, sender=ProductImage)
-def delete_product_image_images(sender, instance, **kwargs):
- """Deletes ProductImage image renditions on post_delete."""
- # Deletes Image Renditions
- instance.image.delete_all_created_images()
- # Deletes Original Image
- instance.image.delete(save=False)
-
-
class VariantImage(models.Model):
variant = models.ForeignKey(
'ProductVariant', related_name='variant_images',
diff --git a/tests/test_product.py b/tests/test_product.py
index 578cebe04e..1123a92955 100644
--- a/tests/test_product.py
+++ b/tests/test_product.py
@@ -547,29 +547,3 @@ def test_create_product_thumbnails(
create_product_thumbnails(product_image.pk)
assert mock_create_thumbnails.called_once_with(
product_image.pk, ProductImage, 'products')
-
-
-@patch('django.db.models.signals.post_delete.send')
-def test_product_image_post_delete_fired(mock_post_delete, product_with_image):
- product_image = product_with_image.images.first()
- product_image.delete()
- assert mock_post_delete.called_once_with(
- sender=ProductImage, instance=product_image)
-
-
-def test_product_image_post_delete(product_with_image):
- product_image = product_with_image.images.first()
- # Generate thumbnails
- create_thumbnails(product_image.pk, ProductImage, 'products')
- sizeset = settings.VERSATILEIMAGEFIELD_RENDITION_KEY_SETS['products']
- # There's no way to list images created by versatile prewarmer
- # So we delete all created thumbnails/crops and count them
- log_deleted_images = io.StringIO()
- with redirect_stdout(log_deleted_images):
- product_image.delete()
- log_deleted_images = log_deleted_images.getvalue()
- deletion_messages = log_deleted_images.split('\n')
- # Some messages can be empty
- deleted_images = list(filter(None, deletion_messages))
- # We should have 1 message for each defined image in the sizeset
- assert len(deleted_images) == len(sizeset)