prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Prevent full disk
  ### Describe the bug
  Sometimes the server's storage gets full, because for some reason filepond uploads aren't being deleted. Today this caused the server to crash (because the full server disk broke redis). We should prevent this from happening in multiple ways:
  
  - Make old uploads be deleted. Would be nice to find out why the uploads aren't being deleted already. But we should also (additionally) periodically remove old files from the media volume.
  - Maybe limit the volume size such that it getting full does not influence the rest of the server. But docker doesn't really support that nicely. We could make a separate volume for it on the host and bind-mount it I guess.
  
  ### How to reproduce
  <!-- Steps to reproduce the behaviour -->
  1. Upload lots of albums to a docker deployment
  2. See the media volume get larger.
  
  ### Expected behaviour
  Stuff is cleaned up once it's processed and periodically.
  
  
  
  
  </issue>
  <code>
  [start of website/photos/tasks.py]
  1 from django.db import transaction
  2 from django.dispatch import Signal
  3 
  4 from celery import shared_task
  5 from django_drf_filepond.models import TemporaryUpload
  6 from django_filepond_widget.fields import FilePondFile
  7 
  8 from photos.models import Album
  9 
  10 from .services import extract_archive
  11 
  12 album_uploaded = Signal()
  13 
  14 
  15 @shared_task
  16 def process_album_upload(archive_upload_id: str, album_id: int):
  17     try:
  18         album = Album.objects.get(id=album_id)
  19     except Album.DoesNotExist:
  20         return
  21 
  22     archive = TemporaryUpload.objects.get(upload_id=archive_upload_id).file
  23     try:
  24         with transaction.atomic():
  25             # We make the upload atomic separately, so we can keep using the db if it fails.
  26             # See https://docs.djangoproject.com/en/4.2/topics/db/transactions/#handling-exceptions-within-postgresql-transactions.
  27             extract_archive(album, archive)
  28             album.is_processing = False
  29             album.save()
  30 
  31             # Send signal to notify that an album has been uploaded. This is used
  32             # by facedetection, and possibly in the future to notify the uploader.
  33             album_uploaded.send(sender=None, album=album)
  34     finally:
  35         if isinstance(archive, FilePondFile):
  36             archive.remove()
  37
  [end of website/photos/tasks.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/website/photos/tasks.py b/website/photos/tasks.py
  --- a/website/photos/tasks.py
  +++ b/website/photos/tasks.py
  @@ -3,7 +3,6 @@
   
   from celery import shared_task
   from django_drf_filepond.models import TemporaryUpload
  -from django_filepond_widget.fields import FilePondFile
   
   from photos.models import Album
   
  @@ -19,7 +18,8 @@
       except Album.DoesNotExist:
           return
   
  -    archive = TemporaryUpload.objects.get(upload_id=archive_upload_id).file
  +    upload = TemporaryUpload.objects.get(upload_id=archive_upload_id)
  +    archive = upload.file
       try:
           with transaction.atomic():
               # We make the upload atomic separately, so we can keep using the db if it fails.
  @@ -32,5 +32,5 @@
               # by facedetection, and possibly in the future to notify the uploader.
               album_uploaded.send(sender=None, album=album)
       finally:
  -        if isinstance(archive, FilePondFile):
  -            archive.remove()
  +        archive.delete()
  +        upload.delete()
  
verification_info: {"golden_diff": "diff --git a/website/photos/tasks.py b/website/photos/tasks.py\n--- a/website/photos/tasks.py\n+++ b/website/photos/tasks.py\n@@ -3,7 +3,6 @@\n \n from celery import shared_task\n from django_drf_filepond.models import TemporaryUpload\n-from django_filepond_widget.fields import FilePondFile\n \n from photos.models import Album\n \n@@ -19,7 +18,8 @@\n     except Album.DoesNotExist:\n         return\n \n-    archive = TemporaryUpload.objects.get(upload_id=archive_upload_id).file\n+    upload = TemporaryUpload.objects.get(upload_id=archive_upload_id)\n+    archive = upload.file\n     try:\n         with transaction.atomic():\n             # We make the upload atomic separately, so we can keep using the db if it fails.\n@@ -32,5 +32,5 @@\n             # by facedetection, and possibly in the future to notify the uploader.\n             album_uploaded.send(sender=None, album=album)\n     finally:\n-        if isinstance(archive, FilePondFile):\n-            archive.remove()\n+        archive.delete()\n+        upload.delete()\n", "issue": "Prevent full disk\n### Describe the bug\r\nSometimes the server's storage gets full, because for some reason filepond uploads aren't being deleted. Today this caused the server to crash (because the full server disk broke redis). We should prevent this from happening in multiple ways:\r\n\r\n- Make old uploads be deleted. Would be nice to find out why the uploads aren't being deleted already. But we should also (additionally) periodically remove old files from the media volume.\r\n- Maybe limit the volume size such that it getting full does not influence the rest of the server. But docker doesn't really support that nicely. We could make a separate volume for it on the host and bind-mount it I guess.\r\n\r\n### How to reproduce\r\n<!-- Steps to reproduce the behaviour -->\r\n1. Upload lots of albums to a docker deployment\r\n2. See the media volume get larger.\r\n\r\n### Expected behaviour\r\nStuff is cleaned up once it's processed and periodically.\r\n\r\n\r\n\n", "before_files": [{"content": "from django.db import transaction\nfrom django.dispatch import Signal\n\nfrom celery import shared_task\nfrom django_drf_filepond.models import TemporaryUpload\nfrom django_filepond_widget.fields import FilePondFile\n\nfrom photos.models import Album\n\nfrom .services import extract_archive\n\nalbum_uploaded = Signal()\n\n\n@shared_task\ndef process_album_upload(archive_upload_id: str, album_id: int):\n    try:\n        album = Album.objects.get(id=album_id)\n    except Album.DoesNotExist:\n        return\n\n    archive = TemporaryUpload.objects.get(upload_id=archive_upload_id).file\n    try:\n        with transaction.atomic():\n            # We make the upload atomic separately, so we can keep using the db if it fails.\n            # See https://docs.djangoproject.com/en/4.2/topics/db/transactions/#handling-exceptions-within-postgresql-transactions.\n            extract_archive(album, archive)\n            album.is_processing = False\n            album.save()\n\n            # Send signal to notify that an album has been uploaded. This is used\n            # by facedetection, and possibly in the future to notify the uploader.\n            album_uploaded.send(sender=None, album=album)\n    finally:\n        if isinstance(archive, FilePondFile):\n            archive.remove()\n", "path": "website/photos/tasks.py"}]}