mirror of
https://github.com/Hopiu/django-imagekit.git
synced 2026-03-16 21:30:23 +00:00
Change handling of spec deletion
Though it's not the case with `FileSystemStorage`, attempting to delete a nonexistent file can cause an exception (as in #80). We want to avoid these errors but don't want to suppress others raised in the process of deleting the file, so we first check to see if the file exists.
This commit is contained in:
parent
081a0a0d0f
commit
dd28557323
1 changed files with 5 additions and 4 deletions
|
|
@ -238,10 +238,11 @@ class ImageSpecFile(_ImageSpecFileMixin, ImageFieldFile):
|
|||
self.close()
|
||||
del self.file
|
||||
|
||||
try:
|
||||
self.storage.delete(self.name)
|
||||
except (NotImplementedError, IOError):
|
||||
pass
|
||||
if self.name and self.storage.exists(self.name):
|
||||
try:
|
||||
self.storage.delete(self.name)
|
||||
except NotImplementedError:
|
||||
pass
|
||||
|
||||
# Delete the filesize cache.
|
||||
if hasattr(self, '_size'):
|
||||
|
|
|
|||
Loading…
Reference in a new issue