Added an accessed_date field on TrackFile for easier cache deletion (#189)

This commit is contained in:
Eliot Berriot 2018-05-06 15:36:18 +02:00
commit f343159856
No known key found for this signature in database
GPG key ID: DD6965E2476E5C27
4 changed files with 38 additions and 0 deletions

View file

@ -14,6 +14,7 @@ from django.db.models.functions import Length
from django.db.models import Count
from django.http import StreamingHttpResponse
from django.urls import reverse
from django.utils import timezone
from django.utils.decorators import method_decorator
from rest_framework import viewsets, views, mixins
@ -264,6 +265,10 @@ class TrackFileViewSet(viewsets.ReadOnlyModelViewSet):
except models.TrackFile.DoesNotExist:
return Response(status=404)
# we update the accessed_date
f.accessed_date = timezone.now()
f.save(update_fields=['accessed_date'])
mt = f.mimetype
audio_file = f.audio_file
try: