From 5c0b93b89a1fa04728a0650ddd35a0ec6b5079c3 Mon Sep 17 00:00:00 2001 From: Oleg Yurchik Date: Tue, 12 Mar 2024 20:36:43 +0300 Subject: [PATCH] Fix creating users service --- sapphire/projects/api/rest/projects/handlers.py | 2 +- sapphire/users/api/rest/users/handlers.py | 2 +- sapphire/users/api/service.py | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sapphire/projects/api/rest/projects/handlers.py b/sapphire/projects/api/rest/projects/handlers.py index 60545f5a..eca04e79 100644 --- a/sapphire/projects/api/rest/projects/handlers.py +++ b/sapphire/projects/api/rest/projects/handlers.py @@ -142,7 +142,7 @@ async def partial_update_project( async def get_project_avatar( project: Project = fastapi.Depends(get_path_project), ) -> FileResponse: - if project.avatar is None: + if project.avatar is None or not pathlib.Path(project.avatar).is_file(): return None return FileResponse(project.avatar) diff --git a/sapphire/users/api/rest/users/handlers.py b/sapphire/users/api/rest/users/handlers.py index 4a76a9af..1fa06d18 100644 --- a/sapphire/users/api/rest/users/handlers.py +++ b/sapphire/users/api/rest/users/handlers.py @@ -56,7 +56,7 @@ async def update_user( async def get_user_avatar(user: User = fastapi.Depends(get_path_user)) -> FileResponse: - if user.avatar is None: + if user.avatar is None or not pathlib.Path(user.avatar).is_file(): return None return FileResponse(user.avatar) diff --git a/sapphire/users/api/service.py b/sapphire/users/api/service.py index 84d3c714..28c36a0f 100644 --- a/sapphire/users/api/service.py +++ b/sapphire/users/api/service.py @@ -119,6 +119,8 @@ def get_service( habr_career_client=habr_career_client, oauth2_habr_callback_url=settings.oauth2_habr_callback_url, jwt_methods=jwt_methods, + media_dir_path=settings.media_dir_path, + load_file_chunk_size=settings.load_file_chunk_size, version=get_version() or "0.0.0", root_url=str(settings.root_url), root_path=settings.root_path,