Skip to content
This repository has been archived by the owner on Aug 10, 2023. It is now read-only.

Commit

Permalink
Add post delete signal listener for solution archives
Browse files Browse the repository at this point in the history
Fixes: #309
  • Loading branch information
PhilippMatthes authored and martinmo committed Aug 13, 2019
1 parent c9d2492 commit a808cc0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions inloop/solutions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,15 @@ def __str__(self):
return "Solution #%d" % self.id


@receiver(post_delete, sender=Solution, dispatch_uid="delete_solutionfile")
def auto_delete_archive_on_delete(sender, instance, **kwargs):
"""
Removes archive from filesystem when corresponding Solution object is deleted.
"""
if instance.archive and os.path.isfile(instance.archive.path):
os.remove(instance.archive.path)


class SolutionFile(models.Model):
"""Represents a single file as part of a solution."""

Expand Down

0 comments on commit a808cc0

Please sign in to comment.