From 73d843e14674c52e016163846fb4cc1c8a898777 Mon Sep 17 00:00:00 2001 From: Bulat Kurbanov Date: Thu, 15 Dec 2022 17:27:47 +0100 Subject: [PATCH] Add deleting, if can't download from cache --- src/app/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/views.py b/src/app/views.py index 20903ef..6825af6 100644 --- a/src/app/views.py +++ b/src/app/views.py @@ -56,7 +56,7 @@ async def download_cached_file(request: Request, object_id: int, object_type: st ) if not cached_file: - raise HTTPException(status_code=status.HTTP_204_NO_CONTENT) + raise HTTPException(status_code=status.HTTP_404_NOT_FOUND) cache_data = cached_file.data @@ -67,6 +67,7 @@ async def download_cached_file(request: Request, object_id: int, object_type: st ) if data is None: + await CachedFileDB.objects.filter(id=cached_file.id).delete() raise HTTPException(status_code=status.HTTP_204_NO_CONTENT) response, client = data