1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-08-05 13:15:18 +02:00

added-fix-image-deletion

This commit is contained in:
ferdousahmed 2025-06-19 13:42:17 -04:00
parent 71ff217323
commit 0a3ca75dd0

View file

@ -9,6 +9,7 @@ from adventures.serializers import AdventureImageSerializer
from integrations.models import ImmichIntegration from integrations.models import ImmichIntegration
import uuid import uuid
import requests import requests
import os
class AdventureImageViewSet(viewsets.ModelViewSet): class AdventureImageViewSet(viewsets.ModelViewSet):
serializer_class = AdventureImageSerializer serializer_class = AdventureImageSerializer
@ -150,6 +151,9 @@ class AdventureImageViewSet(viewsets.ModelViewSet):
def perform_destroy(self, instance): def perform_destroy(self, instance):
print("perform_destroy") print("perform_destroy")
if instance.image:
if os.path.isfile(instance.image.path):
os.remove(instance.image.path)
return super().perform_destroy(instance) return super().perform_destroy(instance)
def destroy(self, request, *args, **kwargs): def destroy(self, request, *args, **kwargs):