Closed gjstein closed 8 years ago
Thanks for spotting the bug and taking the time to write a fix! I took your code and modified it slightly, basically tricking clear_cache to operate on the old image:
new_image = self.image
self.image = self._old_image
self.clear_cache()
self.image = new_image # Back to the new image.
self._old_image.storage.delete(self._old_image.name) # Delete (old) base image.
Could you try this out please? It works for me, I'd just like a second opinion that all is ok :-)
LGTM. I just tried it out on my server and it's a drop-in replacement for mine. Thanks for the quick fix!
I've just committed some code that should fix this - thanks for your help!
Changing the
image
property of theImageModel
class from the admin interface leaves a number of files on the server. When thesave
function is called, it relies on a call toself.clear_cache()
to delete the images from the server. However, value ofself.image
is changes beforesave
is called, which means that it is looking for the images in the wrong place. Rather, it should be using the value ofself._old_image.name
for calculations.There is no-doubt a more elegant way to factor the code, but I solved the problem by modifying a portion of the
save
function in theImageModel
class: