Skip to content

Commit

Permalink
fix(template): only delete file if it exists
Browse files Browse the repository at this point in the history
Add a check to the `auto_delete_file_on_delete` function in `models.py`
to only delete the template file if it exists.
  • Loading branch information
JohnL17 committed Aug 19, 2024
1 parent 1624693 commit eef255a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion document_merge_service/api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ class Template(models.Model):
def auto_delete_file_on_delete(sender, instance, **kwargs):
"""Delete template file from filesystem when `Template` object is deleted."""

DefaultStorage().delete(instance.template.name)
if instance.template:
DefaultStorage().delete(instance.template.name)


@receiver(models.signals.pre_save, sender=Template)
Expand Down

0 comments on commit eef255a

Please sign in to comment.