From c59bf2fcc98a600a64ad013b7d76de38ba3063e4 Mon Sep 17 00:00:00 2001 From: april Date: Mon, 15 Jan 2024 17:12:26 -0600 Subject: [PATCH] Fix automatic image deletion --- api/database/flights.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api/database/flights.py b/api/database/flights.py index 592649b..7582b91 100644 --- a/api/database/flights.py +++ b/api/database/flights.py @@ -267,8 +267,9 @@ async def delete_flight(id: str) -> FlightDisplaySchema: raise HTTPException(404, "Flight not found") # Delete associated images - for image in flight.images: - await delete_image(image) + if "images" in flight: + for image in flight["images"]: + await delete_image(image) await flight_collection.delete_one({"_id": to_objectid(id)}) return FlightDisplaySchema(**flight_display_helper(flight))