Skip to content

Commit

Permalink
Fixed a bug for removing files for Image and File model. Use storage …
Browse files Browse the repository at this point in the history
…delete mehtod instead of python os file remove. Now it's also working with different file storages backends.
  • Loading branch information
Niels van Dijk committed Feb 7, 2013
1 parent 8e1673c commit 6ae057c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fiber/models.py
Expand Up @@ -310,7 +310,7 @@ def save(self, *args, **kwargs):
super(Image, self).save(*args, **kwargs)

def delete(self, *args, **kwargs):
os.remove(os.path.join(settings.MEDIA_ROOT, str(self.image)))
self.image.storage.delete(self.image.name)
super(Image, self).delete(*args, **kwargs)

def get_image_information(self):
Expand Down Expand Up @@ -346,7 +346,7 @@ def save(self, *args, **kwargs):
super(File, self).save(*args, **kwargs)

def delete(self, *args, **kwargs):
os.remove(os.path.join(settings.MEDIA_ROOT, str(self.file)))
self.file.storage.delete(self.file.name)
super(File, self).delete(*args, **kwargs)

def get_filename(self):
Expand Down

0 comments on commit 6ae057c

Please sign in to comment.