From a32c3d29092a5486dce91fc492cc9f9134ccb3e3 Mon Sep 17 00:00:00 2001 From: Bulat Kurbanov Date: Thu, 11 Aug 2022 22:02:05 +0300 Subject: [PATCH] Add exists check --- src/app/services/cache_updater.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/app/services/cache_updater.py b/src/app/services/cache_updater.py index 52b9668..6ecb848 100644 --- a/src/app/services/cache_updater.py +++ b/src/app/services/cache_updater.py @@ -60,6 +60,11 @@ async def check_books(ctx: dict, *args, **kwargs) -> None: # NOSONAR async def cache_file(book: Book, file_type: str) -> Optional[CachedFile]: + if await CachedFile.objects.filter( + object_id=book.id, object_type=file_type + ).exists(): + return + data = await download(book.source.id, book.remote_id, file_type) if data is None: