Deletion of model instance with a thumbnail field fails with SuspiciousOperation

Create issue
Issue #1494 resolved
caleb smith created an issue

When deleting a Product or Category instance, the cascade delete of ProductImage or CategoryImage triggers the following traceback:

Traceback (most recent call last): File "/home/csmith/Projects/projectname/apps/myapp/", line 15 7, in pull_data get_model(new_app, new_model).objects.all().delete() File "/home/csmith/Envs/projectname/local/lib/python2.7/site-packages/django/ db/models/", line 551, in delete collector.delete() File "/home/csmith/Envs/projectname/local/lib/python2.7/site-packages/django/ db/models/", line 62, in decorated func(self, *args, kwargs) File "/home/csmith/Envs/projectname/local/lib/python2.7/site-packages/django/ db/models/", line 288, in delete sender=model, instance=obj, using=self.using File "/home/csmith/Envs/projectname/local/lib/python2.7/site-packages/django/ dispatch/", line 170, in send response = receiver(signal=self, sender=sender, named) File "/home/csmith/Envs/projectname/local/lib/python2.7/site-packages/satchmo utils/thumbnail/", line 98, in _delete_thumbnail delete_file) File "/home/csmith/Envs/projectname/local/lib/python2.7/site-packages/sorl/th umbnail/", line 15, in delete return default.backend.delete(file, delete_file) File "/home/csmith/Envs/projectname/local/lib/python2.7/site-packages/sorl/th umbnail/", line 76, in delete image_file.delete() File "/home/csmith/Envs/projectname/local/lib/python2.7/site-packages/sorl/th umbnail/", line 130, in delete return File "/home/csmith/Envs/projectname/local/lib/python2.7/site-packages/django/ core/files/", line 230, in delete name = self.path(name) File "/home/csmith/Envs/projectname/local/lib/python2.7/site-packages/django/ core/files/", line 259, in path raise SuspiciousOperation("Attempted access to '%s' denied." % name) SuspiciousOperation: Attempted access to '/images/productimage-picture-default.j pg' denied.

This occurs because the satchmo_utils/thumbnail/ code removes the MEDIA_ROOT portion of an absolute path. Sorl tries to delete files outside of the media tree and can't. Removing the MEDIA_ROOT stripping special behavior makes the deletion work.

This bug occurs with sorl 11.12, 11.12b, and the latest master branch on github

Comments (1)

  1. Log in to comment