From 2bd770a99590a277ab73629a17421f2587e3be7b Mon Sep 17 00:00:00 2001 From: MingxuanGame Date: Sun, 9 Nov 2025 09:35:21 +0800 Subject: [PATCH] fix(user): fix missing greenlet when invalidating cache --- app/router/private/avatar.py | 3 +-- app/router/private/cover.py | 3 +-- app/router/private/user.py | 3 +-- app/router/v2/beatmapset.py | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/app/router/private/avatar.py b/app/router/private/avatar.py index 4a91b56..adf0b4b 100644 --- a/app/router/private/avatar.py +++ b/app/router/private/avatar.py @@ -49,9 +49,8 @@ async def upload_avatar( await storage.write_file(storage_path, content, f"image/{format_}") url = await storage.get_file_url(storage_path) current_user.avatar_url = url - await session.commit() - await cache_service.invalidate_user_cache(current_user.id) + await session.commit() return { "url": url, diff --git a/app/router/private/cover.py b/app/router/private/cover.py index 78dbefb..6ba0fe7 100644 --- a/app/router/private/cover.py +++ b/app/router/private/cover.py @@ -50,9 +50,8 @@ async def upload_cover( await storage.write_file(storage_path, content, f"image/{format_}") url = await storage.get_file_url(storage_path) current_user.cover = UserProfileCover(url=url) - await session.commit() - await cache_service.invalidate_user_cache(current_user.id) + await session.commit() return { "url": url, diff --git a/app/router/private/user.py b/app/router/private/user.py index 66deb58..3646f08 100644 --- a/app/router/private/user.py +++ b/app/router/private/user.py @@ -81,9 +81,8 @@ async def user_rename( "previous_username": current_user.previous_usernames[-1], } session.add(rename_event) - await session.commit() - await cache_service.invalidate_user_cache(current_user.id) + await session.commit() return None diff --git a/app/router/v2/beatmapset.py b/app/router/v2/beatmapset.py index 3001e49..5129c32 100644 --- a/app/router/v2/beatmapset.py +++ b/app/router/v2/beatmapset.py @@ -247,5 +247,5 @@ async def favourite_beatmapset( db.add(favourite) else: await db.delete(existing_favourite) - await db.commit() await cache_service.invalidate_user_beatmapsets_cache(current_user.id) + await db.commit()